コード例 #1
0
ファイル: PaypalAPI.php プロジェクト: kirkbauer2/kirkxc
 /**
  * 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;
 }
コード例 #2
0
ファイル: PaypalWPS.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Returns order items
  *
  * @param \XLite\Model\Order $order Order
  *
  * @return array
  * @see    https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables
  */
 protected function getItems($order)
 {
     $result = array();
     $itemsSubtotal = 0;
     if ($order->countItems()) {
         $index = 1;
         /** @var \XLite\Model\Currency $currency */
         $currency = $order->getCurrency();
         foreach ($order->getItems() as $item) {
             $amt = $currency->roundValue($item->getItemNetPrice());
             $result['amount_' . $index] = $amt;
             /** @var \XLite\Model\Product $product */
             $product = $item->getProduct();
             $result['item_name_' . $index] = $product->getName();
             $qty = $item->getAmount();
             $result['quantity_' . $index] = $qty;
             $itemsSubtotal += $amt * $qty;
             ++$index;
         }
         // Prepare data about discount
         $discount = $currency->roundValue($order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_DISCOUNT));
         if (0 != $discount) {
             $result['discount_amount_cart'] = $discount;
         }
         $result = array_merge($result, array('items_amount' => $itemsSubtotal));
         // Prepare data about summary tax cost
         $taxCost = $currency->roundValue($order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_TAX));
         if (0 < $taxCost) {
             $result['tax_cart'] = $taxCost;
         }
     }
     return $result;
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function countItems()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'countItems', array());
     return parent::countItems();
 }