예제 #1
0
 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 = ShippingMethod::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 = ShippingMethodType::getByID($this->post('shippingMethodTypeID'));
             $shippingMethodTypeMethod = $shippingMethodType->addMethod($this->post());
             //make a shipping method that correlates with it.
             ShippingMethod::add($shippingMethodTypeMethod, $shippingMethodType, $this->post('methodName'), true);
             $this->redirect('/dashboard/store/settings/shipping/success');
         }
     } else {
         $this->add($this->post('shippingMethodTypeID'));
         //$smt = ShippingMethodType::getByID($this->post('shippingMethodTypeID'));
         //$this->set('smt',$smt);
     }
 }
예제 #2
0
 public static function migrateOldShippingMethod(Package $pkg)
 {
     $shippingMethodEnabled = Config::get('vividstore.shippingenabled');
     //if it wasn't even enabled, then why bother.
     if ($shippingMethodEnabled) {
         $basePrice = Config::get('vividstore.shippingbase');
         $perItem = Config::get('vividstore.shippingitem');
         $data = array('baseRate' => $basePrice, 'rateType' => 'quantity', 'perItemRate' => $perItem, 'minimumAmount' => 0, 'maximumAmount' => 0, 'minimumWeight' => 0, 'maximumWeight' => 0, 'countries' => 'all');
         $shippingMethodType = ShippingMethodType::getByHandle('flat_rate');
         $shippingMethodTypeMethod = $shippingMethodType->addMethod($data);
         ShippingMethod::add($shippingMethodTypeMethod, $shippingMethodType, 'Flat Rate', true);
     }
 }