本文整理汇总了PHP中Mage_Sales_Model_Order_Invoice::getOrderCurrencyCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Invoice::getOrderCurrencyCode方法的具体用法?PHP Mage_Sales_Model_Order_Invoice::getOrderCurrencyCode怎么用?PHP Mage_Sales_Model_Order_Invoice::getOrderCurrencyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Invoice
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Invoice::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;
}
示例2: collect
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$currencyFrom = Mage::getModel('directory/currency')->load($invoice->getOrderCurrencyCode());
$currencyTo = $invoice->getStore()->getBaseCurrency();
/* @var $helper Dutycalculator_Charge_Helper_Data */
$helper = Mage::helper('dccharge');
$invoice->setImportDutyTax(0);
$invoice->setBaseImportDutyTax(0);
$invoice->setImportDuty(0);
$invoice->setBaseImportDuty(0);
$invoice->setSalesTax(0);
$invoice->setBaseSalesTax(0);
$invoice->setDeliveryDutyType($invoice->getOrder()->getDeliveryDutyType());
$invoice->setFailedCalculation($invoice->getOrder()->getFailedCalculation());
$invoice->setDcOrderId(0);
foreach ($invoice->getAllItems() as $invoiceItem) {
$invoiceItem->setImportDutyTax(0);
$invoiceItem->setBaseImportDutyTax(0);
$invoiceItem->setImportDuty(0);
$invoiceItem->setBaseImportDuty(0);
$invoiceItem->setSalesTax(0);
$invoiceItem->setBaseSalesTax(0);
}
if ($invoice->getOrder()->getDcOrderId()) {
$result = Dutycalculator_Charge_Model_Importdutytaxes::invoiceCalculation($invoice);
if ($result) {
$amountToInvoice = $result['total'];
$baseAmountToInvoice = $helper->convertPrice($currencyFrom, $currencyTo, $result['total']);
$invoice->setImportDutyTax($result['total']);
$invoice->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $result['total']));
$invoice->setImportDuty($result['duty']);
$invoice->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $result['duty']));
$invoice->setSalesTax($result['sales_tax']);
$invoice->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $result['sales_tax']));
$invoice->setDeliveryDutyType($invoice->getOrder()->getDeliveryDutyType());
$invoice->setFailedCalculation($invoice->getOrder()->getFailedCalculation());
$invoice->setDcOrderId($result['dc_order_id']);
if ($invoice->getOrder()->getDeliveryDutyType() == Dutycalculator_Charge_Helper_Data::DC_DELIVERY_TYPE_DDP) {
$invoice->setGrandTotal($invoice->getGrandTotal() + $amountToInvoice);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmountToInvoice);
$aggregatedItemsValues = array();
foreach ($invoice->getAllItems() as $invoiceItem) {
if ($invoiceItem->getOrderItem()->getParentItemId()) {
continue;
}
$id = $invoiceItem->getOrderItem()->getQuoteItemId();
if (isset($result['items'][$id])) {
$invoiceItem->setImportDutyTax($result['items'][$id]['total']);
$invoiceItem->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['total']));
$invoiceItem->setImportDuty($result['items'][$id]['duty']);
$invoiceItem->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $result['items'][$id]['duty']));
$invoiceItem->setSalesTax($result['items'][$id]['sales_tax']);
$invoiceItem->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] = $invoiceItem->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 ($invoice->getAllItems() as $invoiceItem) {
if ($invoiceItem->getOrderItem()->getParentItemId()) {
continue;
}
$id = $invoiceItem->getOrderItem()->getQuoteItemId();
if (isset($taxes[$id])) {
$invoiceItem->setImportDutyTax($totals[$id]);
$invoiceItem->setBaseImportDutyTax($helper->convertPrice($currencyFrom, $currencyTo, $totals[$id]));
$invoiceItem->setImportDuty($totalDuty[$id]);
$invoiceItem->setBaseImportDuty($helper->convertPrice($currencyFrom, $currencyTo, $totalDuty[$id]));
$invoiceItem->setSalesTax($totalSalesTaxes[$id]);
$invoiceItem->setBaseSalesTax($helper->convertPrice($currencyFrom, $currencyTo, $totalSalesTaxes[$id]));
}
if ($invoiceItem->getQty() == 0) {
$invoiceItem->setImportDutyTax(0);
$invoiceItem->setBaseImportDutyTax(0);
$invoiceItem->setImportDuty(0);
$invoiceItem->setBaseImportDuty(0);
$invoiceItem->setSalesTax(0);
$invoiceItem->setBaseSalesTax(0);
}
}
}
}
}
//.........这里部分代码省略.........
示例3: invoiceCalculation
public static function invoiceCalculation(Mage_Sales_Model_Order_Invoice $invoice)
{
$params = array();
/* @var $helper Dutycalculator_Charge_Helper_Data */
$helper = Mage::helper('dccharge');
$invoiceItems = $invoice->getAllItems();
$params['calculation_id'] = $invoice->getOrder()->getDcOrderId();
$orderShippingAmount = (double) $invoice->getOrder()->getShippingAmount();
if ($orderShippingAmount) {
foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
if ($previusInvoice->getShippingAmount() && $previusInvoice->getDcOrderId() != 0 && !$previusInvoice->isCanceled()) {
$orderShippingAmount = 0;
}
}
} else {
$orderShippingAmount = 0;
}
$params['shipping'] = $orderShippingAmount;
$params['output_currency'] = $invoice->getOrderCurrencyCode();
$params['cat'] = array();
$params['qty'] = array();
$params['reference'] = array();
$idx = 0;
$itemsToSend = 0;
foreach ($invoiceItems as $invoiceItem) {
$orderItem = $invoiceItem->getOrderItem();
$product = Mage::getModel('catalog/product')->load($orderItem->getProductId());
$qty = $invoiceItem->getQty();
if ($orderItem->getParentItemId() || !$orderItem->getQuoteItemId() || $product->isVirtual() || $qty <= 0) {
continue;
}
$itemsToSend++;
/* @var $invoiceItem Mage_Sales_Model_Order_Invoice_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('invoice_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;
} catch (Exception $ex) {
$result = array();
//.........这里部分代码省略.........
开发者ID:Fishead-Communications,项目名称:dutycalculator_charge_import_duty,代码行数:101,代码来源:Importdutytaxes.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;
}