コード例 #1
0
ファイル: shipping.php プロジェクト: pvernaglia/vivid_store
 public function add_method()
 {
     $data = $this->post();
     $errors = $this->validate($data);
     $this->error = null;
     //clear errors
     $this->error = $errors;
     if (!$errors->has()) {
         if ($this->post('shippingMethodID')) {
             //update
             $shippingMethod = StoreShippingMethod::getByID($this->post('shippingMethodID'));
             $shippingMethodTypeMethod = $shippingMethod->getShippingMethodTypeMethod();
             $shippingMethodTypeMethod->update($this->post());
             $shippingMethod->update($this->post('methodName'), $this->post('methodEnabled'));
             $this->redirect('/dashboard/store/settings/shipping/updated');
         } else {
             //first we send the data to the shipping method type.
             $shippingMethodType = StoreShippingMethodType::getByID($this->post('shippingMethodTypeID'));
             $shippingMethodTypeMethod = $shippingMethodType->addMethod($this->post());
             //make a shipping method that correlates with it.
             StoreShippingMethod::add($shippingMethodTypeMethod, $shippingMethodType, $this->post('methodName'), true);
             $this->redirect('/dashboard/store/settings/shipping/success');
         }
     } else {
         if ($this->post('shippingMethodID')) {
             $this->edit($this->post('shippingMethodID'));
         } else {
             $this->add($this->post('shippingMethodTypeID'));
         }
     }
 }
コード例 #2
0
ファイル: Calculator.php プロジェクト: pvernaglia/vivid_store
 public static function getShippingTotal($smID = null)
 {
     $sessionShippingMethodID = Session::get('smID');
     if ($smID) {
         $shippingMethod = StoreShippingMethod::getByID($smID);
         Session::set('smID', $smID);
     } elseif (!empty($sessionShippingMethodID)) {
         $shippingMethod = StoreShippingMethod::getByID($sessionShippingMethodID);
     } else {
         $shippingTotal = 0;
     }
     if (is_object($shippingMethod)) {
         $shippingTotal = $shippingMethod->getShippingMethodTypeMethod()->getRate();
     } else {
         $shippingTotal = 0;
     }
     return $shippingTotal;
 }