/**
  * {@inheritDoc}
  */
 public function getOrderFormContent($request)
 {
     // TODO: move into controller
     ZenCartMock::startMock(Runtime::getContainer()->get('shoppingCart'));
     $this->prepare();
     $button = $this->module->process_button();
     ZenCartMock::cleanupMock();
     return $button;
 }
示例#2
0
 /**
  * Get available payment types for the cart.
  *
  * <p>Includes logic to handle the <em>freecharger</code> payment type.</p>
  *
  * @return array List of <code>ZMPaymentType</code> instances.
  */
 public function getPaymentTypes()
 {
     $cartTotal = $this->shoppingCart->getTotal();
     ZenCartMock::startMock($this->shoppingCart, $this->shoppingCart->getBillingAddress());
     //TODO: fix
     $shippingCost = isset($_SESSION['shipping']['cost']) ? $_SESSION['shipping']['cost'] : 0;
     $paymentTypeService = $this->container->get('paymentTypeService');
     if (defined('MODULE_PAYMENT_FREECHARGER_STATUS') && MODULE_PAYMENT_FREECHARGER_STATUS && 0 == $cartTotal && 0 == $shippingCost) {
         return array($paymentTypeService->getPaymentTypeForId('freecharger'));
     }
     // all available except freecharger
     $paymentTypes = $paymentTypeService->getPaymentTypes();
     if (array_key_exists('freecharger', $paymentTypes)) {
         unset($paymentTypes['freecharger']);
     }
     ZenCartMock::cleanupMock();
     return $paymentTypes;
 }
 /**
  * {@inheritDoc}
  */
 public function getShippingMethods(ShoppingCart $shoppingCart, $address = null)
 {
     if (null == $address) {
         // now we just want the shipping method, but we need an address right now...
         $address = $shoppingCart->getShippingAddress();
     }
     $this->errors = array();
     ZenCartMock::startMock($shoppingCart, $address);
     // create new instance for each quote!
     // this is required as most modules do stuff in the c'tor (for example zone checks)
     $clazzName = get_class($this->zenModule);
     $module = new $clazzName();
     $quotes = $module->quote();
     // capture error(s)
     if (is_array($quotes) && array_key_exists('error', $quotes)) {
         $this->errors = array($quotes['error']);
         return array();
     }
     // capture tax
     $taxRate = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\TaxRate');
     $taxRate->setRate(isset($quotes['tax']) ? $quotes['tax'] : 0);
     $methods = array();
     if (is_array($quotes) && array_key_exists('methods', $quotes)) {
         foreach ($quotes['methods'] as $method) {
             $shippingMethod = new ShippingMethodWrapper($this, $method);
             $shippingMethod->setProvider($this);
             $shippingMethod->setTaxRate($taxRate);
             $methods[$shippingMethod->getId()] = $shippingMethod;
         }
     }
     ZenCartMock::cleanupMock();
     return $methods;
 }