当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode怎么用?PHP Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Order_Creditmemo的用法示例。


在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCurrency

 /**
  * Returns the currency compliant to ISO 4217 (3 char code)
  * @return string 3 Character long currency code
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
  * @return string
  */
 public function getCurrency($object)
 {
     $currency = $object->getBaseCurrencyCode();
     if (!Mage::helper('paymill/optionHelper')->isBaseCurrency()) {
         if ($object instanceof Mage_Sales_Model_Quote) {
             $currency = $object->getQuoteCurrencyCode();
         } else {
             $currency = $object->getOrderCurrencyCode();
         }
     }
     return $currency;
 }
开发者ID:SiWe0401,项目名称:paymill-magento,代码行数:19,代码来源:PaymentHelper.php

示例2: creditMemoCalculation

 public static function creditMemoCalculation(Mage_Sales_Model_Order_Creditmemo $creditMemo)
 {
     $params = array();
     /* @var $helper Dutycalculator_Charge_Helper_Data */
     $helper = Mage::helper('dccharge');
     $creditMemoItems = $creditMemo->getAllItems();
     $params['calculation_id'] = $creditMemo->getOrder()->getDcOrderId();
     $params['shipping'] = (double) $creditMemo->getShippingAmount();
     $params['output_currency'] = $creditMemo->getOrderCurrencyCode();
     $params['cat'] = array();
     $params['qty'] = array();
     $params['reference'] = array();
     $idx = 0;
     $itemsToSend = 0;
     foreach ($creditMemoItems as $creditMemoItem) {
         $orderItem = $creditMemoItem->getOrderItem();
         $product = Mage::getModel('catalog/product')->load($orderItem->getProductId());
         $qty = $creditMemoItem->getQty();
         if ($orderItem->getParentItemId() || !$orderItem->getQuoteItemId() || $product->isVirtual() || $qty <= 0) {
             continue;
         }
         $itemsToSend++;
         /* @var $creditMemoItem Mage_Sales_Model_Order_Creditmemo_Item */
         /* @var $product Mage_Catalog_Model_Product */
         $params['qty'][$idx] = (double) $qty;
         $params['reference'][$idx] = $orderItem->getQuoteItemId();
         if ($product->getDcProductId()) {
             $params['cat'][$idx] = $product->getDcProductId();
         } else {
             $params['cat'][$idx] = '';
         }
         $idx++;
     }
     if ($itemsToSend > 0) {
         $rawXml = $helper->sendRequest('credit_note_calculation', $params);
         try {
             if (stripos($rawXml, '<?xml') === false) {
                 throw new Exception($rawXml);
             }
             $answer = new SimpleXMLElement($rawXml);
             $answerAttributes = $answer->attributes();
             $dcOrderId = (int) $answerAttributes['id'];
             $totals = current($answer->xpath('total-charges'));
             $items = $answer->xpath('item');
             $result = array();
             $result['dc_order_id'] = $dcOrderId;
             $result['total'] = (double) $totals->total->amount;
             $result['duty'] = (double) $totals->duty->amount;
             $additionalTaxes = $totals->xpath('additional-import-taxes');
             if ($additionalTaxes) {
                 $additionalTaxes = current($additionalTaxes);
                 foreach ($additionalTaxes->tax as $additionalTax) {
                     $result['duty'] += (double) $additionalTax->amount;
                 }
             }
             $result['sales_tax'] = (double) current($totals->xpath('sales-tax'))->amount;
             $result['items'] = array();
             $result['aggregated_items'] = array();
             foreach ($items as $item) {
                 $attributes = $item->attributes();
                 $references = explode(',', (string) $attributes->reference);
                 if (count($references) > 1) {
                     $total = (double) $item->total->amount;
                     $duty = (double) $item->duty->amount;
                     $additionalTaxes = $item->xpath('additional-import-taxes');
                     if ($additionalTaxes) {
                         $additionalTaxes = current($additionalTaxes);
                         foreach ($additionalTaxes->tax as $additionalTax) {
                             $duty += (double) $additionalTax->amount;
                         }
                     }
                     $salesTax = (double) current($item->xpath('sales-tax'))->amount;
                     $result['aggregated_items'][(string) $attributes->reference] = array('items' => $references, 'aggregated_total' => $total, 'aggregated_duty' => $duty, 'aggregated_sales_tax' => $salesTax);
                 } else {
                     $total = (double) $item->total->amount;
                     $duty = (double) $item->duty->amount;
                     $additionalTaxes = $item->xpath('additional-import-taxes');
                     if ($additionalTaxes) {
                         $additionalTaxes = current($additionalTaxes);
                         foreach ($additionalTaxes->tax as $additionalTax) {
                             $duty += (double) $additionalTax->amount;
                         }
                     }
                     $salesTax = (double) current($item->xpath('sales-tax'))->amount;
                     $result['items'][(string) $attributes->reference] = array('total' => $total, 'duty' => $duty, 'sales_tax' => $salesTax);
                 }
             }
             return $result;
             //(float)$totals->total->amount;
         } catch (Exception $ex) {
             $result = array();
             $result['failed_calculation'] = 1;
             $result['dc_order_id'] = 0;
             $result['total'] = 0;
             $result['duty'] = 0;
             $result['sales_tax'] = 0;
             $result['items'] = array();
             $result['aggregated_items'] = array();
             return $result;
         }
//.........这里部分代码省略.........
开发者ID:Fishead-Communications,项目名称:dutycalculator_charge_import_duty,代码行数:101,代码来源:Importdutytaxes.php

示例3: collect

 public function collect(Mage_Sales_Model_Order_Creditmemo $creditMemo)
 {
     $currencyFrom = Mage::getModel('directory/currency')->load($creditMemo->getOrderCurrencyCode());
     $currencyTo = $creditMemo->getStore()->getBaseCurrency();
     /* @var $helper Dutycalculator_Charge_Helper_Data */
     $helper = Mage::helper('dccharge');
     $creditMemo->setImportDutyTax(0);
     $creditMemo->setBaseImportDutyTax(0);
     $creditMemo->setImportDuty(0);
     $creditMemo->setBaseImportDuty(0);
     $creditMemo->setSalesTax(0);
     $creditMemo->setBaseSalesTax(0);
     $creditMemo->setDeliveryDutyType($creditMemo->getOrder()->getDeliveryDutyType());
     $creditMemo->setFailedCalculation($creditMemo->getOrder()->getFailedCalculation());
     $creditMemo->setDcOrderId(0);
     foreach ($creditMemo->getAllItems() as $creditMemoItem) {
         $creditMemoItem->setImportDutyTax(0);
         $creditMemoItem->setBaseImportDutyTax(0);
         $creditMemoItem->setImportDuty(0);
         $creditMemoItem->setBaseImportDuty(0);
         $creditMemoItem->setSalesTax(0);
         $creditMemoItem->setBaseSalesTax(0);
     }
     if ($creditMemo->getOrder()->getDcOrderId()) {
         $result = Dutycalculator_Charge_Model_Importdutytaxes::creditMemoCalculation($creditMemo);
         if ($result) {
             $amountToRefund = $result['total'];
             $baseAmountToRefund = $helper->convertPrice($currencyFrom, $currencyTo, $result['total']);
             $creditMemo->setDeliveryDutyType($creditMemo->getOrder()->getDeliveryDutyType());
             $creditMemo->setFailedCalculation($creditMemo->getOrder()->getFailedCalculation());
             $creditMemo->setImportDutyTax($result['total']);
             $creditMemo->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $result['total']));
             $creditMemo->setImportDuty($result['duty']);
             $creditMemo->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $result['duty']));
             $creditMemo->setSalesTax($result['sales_tax']);
             $creditMemo->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $result['sales_tax']));
             $creditMemo->setDcOrderId($result['dc_order_id']);
             if ($creditMemo->getOrder()->getDeliveryDutyType() == Dutycalculator_Charge_Helper_Data::DC_DELIVERY_TYPE_DDP) {
                 $creditMemo->setGrandTotal($creditMemo->getGrandTotal() + $amountToRefund);
                 $creditMemo->setBaseGrandTotal($creditMemo->getBaseGrandTotal() + $baseAmountToRefund);
                 $aggregatedItemsValues = array();
                 foreach ($creditMemo->getAllItems() as $creditMemoItem) {
                     if ($creditMemoItem->getOrderItem()->getParentItemId()) {
                         continue;
                     }
                     $id = $creditMemoItem->getOrderItem()->getQuoteItemId();
                     if (isset($result['items'][$id])) {
                         $creditMemoItem->setImportDutyTax($result['items'][$id]['total']);
                         $creditMemoItem->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['total']));
                         $creditMemoItem->setImportDuty($result['items'][$id]['duty']);
                         $creditMemoItem->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['duty']));
                         $creditMemoItem->setSalesTax($result['items'][$id]['sales_tax']);
                         $creditMemoItem->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['sales_tax']));
                     } else {
                         foreach ($result['aggregated_items'] as $key => $_items) {
                             if (in_array($id, $_items['items'])) {
                                 $aggregatedItemsValues[$key][$id] = $creditMemoItem->getRowTotal();
                             }
                         }
                     }
                 }
                 $totals = array();
                 $totalDuty = array();
                 $totalSalesTaxes = array();
                 foreach ($aggregatedItemsValues as $key => $aggregatedItemsValue) {
                     $aggregatedTotal = $result['aggregated_items'][$key]['aggregated_total'];
                     $aggregatedDuty = $result['aggregated_items'][$key]['aggregated_duty'];
                     $aggregatedSalesTax = $result['aggregated_items'][$key]['aggregated_sales_tax'];
                     $totalAggregatedItemsValue = array_sum($aggregatedItemsValue);
                     foreach ($aggregatedItemsValue as $itemId => $value) {
                         $totals[$itemId] = round($value / $totalAggregatedItemsValue * $aggregatedTotal, 2);
                         $totalDuty[$itemId] = round($value / $totalAggregatedItemsValue * $aggregatedDuty, 2);
                         $totalSalesTaxes[$itemId] = round($value / $totalAggregatedItemsValue * $aggregatedSalesTax, 2);
                     }
                 }
                 foreach ($creditMemo->getAllItems() as $creditMemoItem) {
                     if ($creditMemoItem->getOrderItem()->getParentItemId()) {
                         continue;
                     }
                     $id = $creditMemoItem->getOrderItem()->getQuoteItemId();
                     if (isset($taxes[$id])) {
                         $creditMemoItem->setImportDutyTax($totals[$id]);
                         $creditMemoItem->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $totals[$id]));
                         $creditMemoItem->setImportDuty($totalDuty[$id]);
                         $creditMemoItem->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $totalDuty[$id]));
                         $creditMemoItem->setSalesTax($totalSalesTaxes[$id]);
                         $creditMemoItem->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $totalSalesTaxes[$id]));
                     }
                     if ($creditMemoItem->getQty() == 0) {
                         $creditMemoItem->setImportDutyTax(0);
                         $creditMemoItem->setBaseImportDutyTax(0);
                         $creditMemoItem->setImportDuty(0);
                         $creditMemoItem->setBaseImportDuty(0);
                         $creditMemoItem->setSalesTax(0);
                         $creditMemoItem->setBaseSalesTax(0);
                     }
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:Fishead-Communications,项目名称:dutycalculator_charge_import_duty,代码行数:101,代码来源:Creditmemo.php

示例4: getRequestBasket

 /**
  * Gets all needed Informations for shopping-basket Block of the Request
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
  * @param float $amount
  * @param array $articleList
  * @return array
  */
 public function getRequestBasket($object, $amount = '', $articleList = '')
 {
     $basket = array();
     if ($object instanceof Mage_Sales_Model_Order) {
         $basket['currency'] = $object->getOrderCurrencyCode();
     } else {
         if ($object instanceof Mage_Sales_Model_Quote) {
             $basket['currency'] = $object->getQuoteCurrencyCode();
         } else {
             $basket['currency'] = $object->getOrder()->getOrderCurrencyCode();
         }
     }
     if ($articleList != '') {
         $basket['items'] = $articleList;
     } else {
         $basket['items'] = $this->getArticles($object);
     }
     // If no positiv item is remained in basket clear basket
     if (!$this->_anyPositiveItems($basket['items'])) {
         $basket['items'] = array();
     }
     if (is_numeric($amount)) {
         $basket['amount'] = $amount;
     } else {
         if ($object->getGrandTotal() > 0) {
             $basket['amount'] = $object->getGrandTotal();
         } elseif (count($basket['items']) == 0) {
             $basket['amount'] = 0;
         } else {
             $basket['amount'] = $this->getAmountByItems($basket['items']);
         }
     }
     // Ensure that the basket amount is never less than zero
     // In certain cases (i.e. in case of maloperation) the amount can become < 0
     if ($basket['amount'] < 0) {
         $basket['amount'] = 0;
     }
     return $basket;
 }
开发者ID:ratepay,项目名称:magento-module,代码行数:47,代码来源:Mapping.php


注:本文中的Mage_Sales_Model_Order_Creditmemo::getOrderCurrencyCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。