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')); } } }
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; }
public function delete() { $methods = StoreShippingMethod::getAvailableMethods($this->getShippingMethodTypeID()); foreach ($methods as $method) { $method->delete(); } $em = Database::get()->getEntityManager(); $em->remove($this); $em->flush(); }
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 = StoreShippingMethodType::getByHandle('flat_rate'); $shippingMethodTypeMethod = $shippingMethodType->addMethod($data); StoreShippingMethod::add($shippingMethodTypeMethod, $shippingMethodType, 'Flat Rate', true); } }
<?php defined('C5_EXECUTE') or die("Access Denied."); use Concrete\Package\VividStore\Src\VividStore\Shipping\ShippingMethod as StoreShippingMethod; use Concrete\Package\VividStore\Src\VividStore\Utilities\Price as StorePrice; $eligibleMethods = StoreShippingMethod::getEligibleMethods(); $i = 1; foreach ($eligibleMethods as $method) { $sessionShippingMethodID = Session::get('smID'); if ($sessionShippingMethodID == $method->getShippingMethodID()) { $checked = true; } else { if ($i == 1) { $checked = true; } else { $checked = false; } } ?> <div class="radio"> <label> <input type="radio" name="shippingMethod" value="<?php echo $method->getShippingMethodID(); ?> "<?php if ($checked) { echo " checked"; } ?> > <?php
foreach ($methodTypes as $methodType) { ?> <table class="table table-striped"> <thead> <th><?php echo $methodType->getShippingMethodTypeName() . t(" Methods"); ?> </th> <th class="text-right"><?php echo t("Actions"); ?> </th> </thead> <tbody> <?php foreach (StoreShippingMethod::getAvailableMethods($methodType->getShippingMethodTypeID()) as $method) { ?> <tr> <td><?php echo $method->getName(); ?> </td> <td class="text-right"> <a href="<?php echo URL::to('/dashboard/store/settings/shipping/edit', $method->getShippingMethodID()); ?> " class="btn btn-default"><?php echo t("Edit"); ?> </a> <a href="<?php
/** * @param array $data * @param StorePaymentMethod $pm * @param string $transactionReference * @param boolean $status * @return Order */ public function add($data, $pm, $transactionReference = '', $status = null) { $customer = new StoreCustomer(); $now = new \DateTime(); $smName = StoreShippingMethod::getActiveShippingMethodName(); $shippingTotal = StoreCalculator::getShippingTotal(); $taxes = StoreTax::getConcatenatedTaxStrings(); $totals = StoreCalculator::getTotals(); $total = $totals['total']; $pmName = $pm->getPaymentMethodName(); $order = new Order(); $order->setCustomerID($customer->getUserID()); $order->setOrderDate($now); $order->setPaymentMethodName($pmName); $order->setShippingMethodName($smName); $order->setShippingTotal($shippingTotal); $order->setTaxTotals($taxes['taxTotals']); $order->setTaxIncluded($taxes['taxIncludedTotal']); $order->setTaxLabels($taxes['taxLabels']); $order->setOrderTotal($total); $order->save(); $customer->setLastOrderID($order->getOrderID()); $order->updateStatus($status); $order->addCustomerAddress($customer, $order->isShippable()); $order->addOrderItems(StoreCart::getCart()); $order->createNeededAccounts(); $order->assignFilePermissions(); if (!$pm->getMethodController()->external) { $order->completeOrder($transactionReference); } return $order; }
public function isShippable() { $shippableItems = self::getShippableItems(); $shippingMethods = StoreShippingMethod::getAvailableMethods(); if (count($shippingMethods) > 0) { if (count($shippableItems) > 0) { return true; } else { return false; } } else { return false; } }