Beispiel #1
0
 /**
  * Returns order items
  *
  * @param \XLite\Model\Order $order Order
  *
  * @return array
  */
 protected function getItems($order)
 {
     $result = array();
     $itemsSubtotal = 0;
     if ($order->countItems()) {
         $index = 0;
         /** @var \XLite\Model\Currency $currency */
         $currency = $order->getCurrency();
         foreach ($order->getItems() as $item) {
             $amt = $currency->roundValue($item->getItemNetPrice());
             $result['L_PAYMENTREQUEST_0_AMT' . $index] = $amt;
             /** @var \XLite\Model\Product $product */
             $product = $item->getProduct();
             $result['L_PAYMENTREQUEST_0_NAME' . $index] = $product->getName();
             if ($product->getSku()) {
                 $result['L_PAYMENTREQUEST_0_NUMBER' . $index] = $product->getSku();
             }
             $qty = $item->getAmount();
             $result['L_PAYMENTREQUEST_0_QTY' . $index] = $qty;
             $itemsSubtotal += $amt * $qty;
             $index += 1;
         }
         // Prepare data about discount
         $discount = $currency->roundValue($order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_DISCOUNT));
         if (0 != $discount) {
             $result['L_PAYMENTREQUEST_0_AMT' . $index] = $discount;
             $result['L_PAYMENTREQUEST_0_NAME' . $index] = 'Discount';
             $result['L_PAYMENTREQUEST_0_QTI' . $index] = 1;
             $itemsSubtotal += $discount;
         }
         $result += array('PAYMENTREQUEST_0_ITEMAMT' => $itemsSubtotal);
         // Prepare data about summary tax cost
         $taxCost = $currency->roundValue($order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_TAX));
         if (0 < $taxCost) {
             $result['L_PAYMENTREQUEST_0_TAXAMT' . $index] = $taxCost;
             $result['PAYMENTREQUEST_0_TAXAMT'] = $taxCost;
         }
     }
     return $result;
 }
Beispiel #2
0
 /**
  * Get shipping cost for set express checkout
  *
  * @param \XLite\Model\Order $order Order
  *
  * @return float
  */
 protected function getShippingCost($order)
 {
     $result = null;
     $shippingModifier = $order->getModifier(\XLite\Model\Base\Surcharge::TYPE_SHIPPING, 'SHIPPING');
     if ($shippingModifier && $shippingModifier->canApply()) {
         /** @var \XLite\Model\Currency $currency */
         $currency = $order->getCurrency();
         $result = $currency->roundValue($order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_SHIPPING));
     }
     return $result;
 }
 /**
  * {@inheritDoc}
  */
 public function getSurchargeSumByType($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSurchargeSumByType', array($type));
     return parent::getSurchargeSumByType($type);
 }