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


PHP Mage_Sales_Model_Order::getShippingDiscountAmount方法代码示例

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


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

示例1: _prepareOrderData

 /**
  * @return array
  */
 protected function _prepareOrderData()
 {
     // magento 1.5 compat
     $shipping_method_c = $this->_order->getShippingMethod(true);
     $shipping_method = $this->_order->getData('shipping_method');
     $shipping_method_code = $shipping_method_c ? $shipping_method_c->getData('carrier_code') : $shipping_method;
     $data = array_filter(array('currency_code' => $this->_order->getOrderCurrencyCode(), 'shipping_method_code' => $shipping_method_code, 'shipping_method_title' => $this->_order->getShippingDescription(), 'created_on' => $this->_order->getCreatedAt(), 'updated_on' => $this->_order->getUpdatedAt(), 'state' => $this->_order->getState(), 'status' => $this->_order->getStatus(), 'is_gift' => $this->_order->getGiftMessageId() != null, 'ref_quote_id' => $this->_order->getQuoteId(), 'order_subtotal_with_tax' => $this->_order->getSubtotalInclTax(), 'order_subtotal' => $this->_order->getSubtotal(), 'order_tax' => $this->_order->getTaxAmount(), 'order_hidden_tax' => $this->_order->getHiddenTaxAmount(), 'order_shipping_with_tax' => $this->_order->getShippingInclTax(), 'order_shipping' => $this->_order->getShippingAmount(), 'order_discount' => $this->_order->getDiscountAmount(), 'order_shipping_discount' => $this->_order->getShippingDiscountAmount(), 'order_total' => $this->_order->getGrandTotal(), 'order_total_items' => $this->_order->getTotalItemCount()));
     return $data;
 }
开发者ID:payin7-payments,项目名称:payin7-magento,代码行数:12,代码来源:Submit.php

示例2: createFromOrder

 public static function createFromOrder(Mage_Sales_Model_Order $order)
 {
     $address = $order->getShippingAddress();
     $shippingInfo = new self();
     $shippingInfo->first_name = $address->getFirstname();
     $shippingInfo->last_name = $address->getLastname();
     $shippingInfo->street = $address->getStreet(1);
     $shippingInfo->city = $address->getCity();
     $shippingInfo->state = $address->getRegion();
     $shippingInfo->country = $address->getCountryModel()->getIso2Code();
     $shippingInfo->postcode = $address->getPostcode();
     $shippingInfo->name = $order->getShippingMethod();
     $shippingInfo->price = Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getShippingAmount());
     $shippingInfo->phone = $address->getTelephone();
     $shippingInfo->alt_phone = $address->getAltTelephone();
     $shippingInfo->address_addition = $address->getStreet(2);
     if ($order->getShippingAmount() > 0) {
         $shippingInfo->tax_rate = Aplazame_Sdk_Serializer_Decimal::fromFloat(100 * $order->getShippingTaxAmount() / $order->getShippingAmount());
     }
     $shippingInfo->discount = Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getShippingDiscountAmount());
     return $shippingInfo;
 }
开发者ID:aplazame,项目名称:magento,代码行数:22,代码来源:ShippingInfo.php

示例3: addOrderLine

 /**
  * Add PayEx Single Order Line
  * @param string $orderRef
  * @param Mage_Sales_Model_Order $order
  * @return bool
  */
 public function addOrderLine($orderRef, $order)
 {
     // add Order Items
     $items = $order->getAllVisibleItems();
     $i = 1;
     /** @var $item Mage_Sales_Model_Order_Item */
     foreach ($items as $item) {
         // @todo Calculate prices using Discount Rules
         // @todo Get children products from bundle
         //if (!$item->getNoDiscount()) {
         //    Mage::helper('payexautopay/tools')->addToDebug('Warning: The product has a discount. There might be problems.', $order->getIncrementId());
         //}
         $itemQty = (int) $item->getQtyOrdered();
         //$taxPrice = $item->getTaxAmount();
         $taxPrice = $itemQty * $item->getPriceInclTax() - $itemQty * $item->getPrice();
         $taxPercent = $item->getTaxPercent();
         $priceWithTax = $itemQty * $item->getPriceInclTax();
         // Calculate tax percent for Bundle products
         if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
             $taxPercent = $taxPrice > 0 ? round(100 / (($priceWithTax - $taxPrice) / $taxPrice)) : 0;
         }
         $params = array('accountNumber' => '', 'orderRef' => $orderRef, 'itemNumber' => $i, 'itemDescription1' => $item->getName(), 'itemDescription2' => '', 'itemDescription3' => '', 'itemDescription4' => '', 'itemDescription5' => '', 'quantity' => $itemQty, 'amount' => (int) (100 * $priceWithTax), 'vatPrice' => (int) (100 * $taxPrice), 'vatPercent' => (int) (100 * $taxPercent));
         $result = Mage::helper('payexautopay/api')->getPx()->AddSingleOrderLine2($params);
         Mage::helper('payexautopay/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
         $i++;
     }
     // add Shipping
     if (!$order->getIsVirtual()) {
         $shipping = $order->getShippingAmount();
         $shippingIncTax = $order->getShippingInclTax();
         $shippingTax = $order->getShippingTaxAmount();
         $params = array('accountNumber' => '', 'orderRef' => $orderRef, 'itemNumber' => $i, 'itemDescription1' => $order->getShippingDescription(), 'itemDescription2' => '', 'itemDescription3' => '', 'itemDescription4' => '', 'itemDescription5' => '', 'quantity' => 1, 'amount' => (int) (100 * $shippingIncTax), 'vatPrice' => (int) (100 * $shippingTax), 'vatPercent' => $shipping != 0 ? round(100 * 100 * $shippingTax / $shipping) : 0);
         $result = Mage::helper('payexautopay/api')->getPx()->AddSingleOrderLine2($params);
         Mage::helper('payexautopay/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
         $i++;
     }
     // add Discount
     $discount = $order->getDiscountAmount() + $order->getShippingDiscountAmount();
     if (abs($discount) > 0) {
         $params = array('accountNumber' => '', 'orderRef' => $orderRef, 'itemNumber' => $i, 'itemDescription1' => $order->getDiscountDescription() !== null ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount'), 'itemDescription2' => '', 'itemDescription3' => '', 'itemDescription4' => '', 'itemDescription5' => '', 'quantity' => 1, 'amount' => (int) (100 * $discount), 'vatPrice' => 0, 'vatPercent' => 0);
         $result = Mage::helper('payexautopay/api')->getPx()->AddSingleOrderLine2($params);
         Mage::helper('payexautopay/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
         $i++;
     }
     // Add reward points
     if ((double) $order->getBaseRewardCurrencyAmount() > 0) {
         $params = array('accountNumber' => '', 'orderRef' => $orderRef, 'itemNumber' => $i, 'itemDescription1' => Mage::helper('payexautopay')->__('Reward points'), 'itemDescription2' => '', 'itemDescription3' => '', 'itemDescription4' => '', 'itemDescription5' => '', 'quantity' => 1, 'amount' => -1 * (int) (100 * $order->getBaseRewardCurrencyAmount()), 'vatPrice' => 0, 'vatPercent' => 0);
         $result = Mage::helper('payexautopay/api')->getPx()->AddSingleOrderLine2($params);
         Mage::helper('payexautopay/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
         $i++;
     }
     return true;
 }
开发者ID:anziv,项目名称:Magento-modules,代码行数:59,代码来源:Order.php

示例4: _persistOrder


//.........这里部分代码省略.........
             case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
                 if (count($item->getChildrenItems()) > 0) {
                     foreach ($item->getChildrenItems() as $childItem) {
                         if ($childItem->getPrice() != 0) {
                             $item->setPrice(0);
                         }
                         $fullItems[] = $childItem;
                     }
                 }
                 $fullItems[] = $item;
                 break;
                 // Configurable products just need simple config item
             // Configurable products just need simple config item
             case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
                 $childItems = $item->getChildrenItems();
                 if (1 === count($childItems)) {
                     $childItem = $childItems[0];
                     // Collect options applicable to the configurable product
                     $productAttributeOptions = $itemProduct->getTypeInstance(true)->getConfigurableAttributesAsArray($itemProduct);
                     // Build Selected Options Name
                     $nameWithOptions = array();
                     foreach ($productAttributeOptions as $productAttribute) {
                         $itemValue = $productHelper->getProductAttribute($childItem->getProductId(), $productAttribute['attribute_code'], $storeId);
                         $nameWithOptions[] = $productAttribute['label'] . ': ' . $itemValue;
                     }
                     // Set parent product name to include selected options
                     $parentName = $item->getName() . ' [' . implode(', ', $nameWithOptions) . ']';
                     $item->setName($parentName);
                 }
                 $fullItems[] = $item;
                 break;
                 // Grouped products need parent and child items
             // Grouped products need parent and child items
             case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
                 // This condition probably never gets hit, parent grouped items don't show in order
                 $fullItems[] = $item;
                 foreach ($item->getChildrenItems() as $child_item) {
                     $fullItems[] = $child_item;
                 }
                 break;
                 // Anything else (namely simples) just get added to array
             // Anything else (namely simples) just get added to array
             default:
                 $fullItems[] = $item;
                 break;
         }
     }
     // Cycle through newly created array of products
     foreach ($fullItems as $item) {
         // If product has a parent, get that parent product
         $parent = false;
         if ($item->getParentItem()) {
             $parent = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getParentItem()->getProductId());
         }
         /* @var $product Mage_Catalog_Model_Product */
         $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getProductId());
         // If there is a parent product, use that to get category ids
         if ($parent) {
             $categoryIds = $parent->getCategoryIds();
         } else {
             $categoryIds = $product->getCategoryIds();
         }
         // If the product type is simple and the description
         // is empty, then attempt to find a parent product
         // to backfill the description.
         $parentProduct = $productHelper->getConfigurableProduct($product);
         if (!$product->getData($descriptionAttr)) {
             $product->setData($descriptionAttr, $parentProduct->getData($descriptionAttr));
         }
         if (empty($categoryIds)) {
             $categoryIds = $parentProduct->getCategoryIds();
         }
         // Cycle through category ids to pull category details
         $categories = array();
         foreach ($categoryIds as $categoryId) {
             /* @var $category Mage_Catalog_Model_Category */
             $category = Mage::getModel('catalog/category')->load($categoryId);
             $parent = $category->getParentCategory();
             $categories[] = $parent->getUrlKey() ? $parent->getUrlKey() : $parent->formatUrlKey($parent->getName());
             $categories[] = $category->getUrlKey() ? $category->getUrlKey() : $category->formatUrlKey($category->getName());
         }
         // Check to ensure there are no duplicate categories
         $categories = array_unique($categories);
         // Write orderItem
         $brontoOrderItems[] = array('id' => $item->getId(), 'sku' => $item->getSku(), 'name' => $item->getName(), 'description' => $product->getData($descriptionAttr), 'category' => implode(' ', $categories), 'image' => $this->_helper->getItemImg($item, $product, $storeId), 'url' => $this->_helper->getItemUrl($item, $product, $storeId), 'quantity' => (int) $item->getQtyOrdered(), 'price' => $this->_helper->getItemPrice($item, $basePrefix, $inclTaxes, $inclDiscounts));
     }
     if ($inclShipping && $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE && $order->hasShipments()) {
         $shippingObject = new Varien_Object(array('qty_ordered' => 1, 'base_row_total' => $order->getBaseShippingAmount(), 'row_total' => $order->getShippingAmount(), 'base_tax_amount' => $order->getBaseShippingTaxAmount(), 'tax_amount' => $order->getShippingTaxAmount(), 'base_discount_amount' => $order->getBaseShippingDiscountAmount(), 'discount_amount' => $order->getShippingDiscountAmount()));
         $descriptions = array();
         foreach ($order->getTracksCollection() as $track) {
             if ($track->hasTrackNumber() && $track->hasTitle()) {
                 $descriptions[] = "{$track->getTitle()} - {$track->getTrackNumber()}";
             }
         }
         $shipmentItem = array('sku' => 'SHIPPING', 'name' => $order->getShippingDescription(), 'description' => implode("<br/>", $descriptions), 'quantity' => 1, 'price' => $this->_helper->getItemPrice($shippingObject, $basePrefix, $inclTaxes, $inclDiscounts));
         $brontoOrderItems[] = $shipmentItem;
     }
     $brontoOrder->products = $brontoOrderItems;
     $brontoOrder->persist();
 }
开发者ID:bevello,项目名称:bevello,代码行数:101,代码来源:Observer.php

示例5: getOrderDiscountData

 /**
  * Gets the total discount from $order
  * inkl. and excl. tax
  * Data is returned as a Varien_Object with these data-keys set:
  *  - discount_incl_tax
  *  - discount_excl_tax
  *
  * @param Mage_Sales_Model_Order $order
  *
  * @return Varien_Object
  */
 public function getOrderDiscountData(Mage_Sales_Model_Order $order)
 {
     // if catalog-prices includes tax
     $CatPriceIncl = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $order->getStore());
     $discountIncl = 0;
     $discountExcl = 0;
     // find discount on the items
     foreach ($order->getItemsCollection() as $item) {
         /** @var Mage_Sales_Model_Quote_Item $item */
         if (!$CatPriceIncl) {
             $discountExcl += $item->getDiscountAmount();
             $discountIncl += $item->getDiscountAmount() * ($item->getTaxPercent() / 100 + 1);
         } else {
             $discountExcl += $item->getDiscountAmount() / ($item->getTaxPercent() / 100 + 1);
             $discountIncl += $item->getDiscountAmount();
         }
     }
     // find out tax-rate for the shipping
     if ((double) $order->getShippingInclTax() && (double) $order->getShippingAmount()) {
         $shippingTaxRate = $order->getShippingInclTax() / $order->getShippingAmount();
     } else {
         $shippingTaxRate = 1;
     }
     // get discount amount for shipping
     $shippingDiscount = (double) $order->getShippingDiscountAmount();
     // apply/remove tax to shipping-discount
     if (!$CatPriceIncl) {
         $discountIncl += $shippingDiscount * $shippingTaxRate;
         $discountExcl += $shippingDiscount;
     } else {
         $discountIncl += $shippingDiscount;
         $discountExcl += $shippingDiscount / $shippingTaxRate;
     }
     $return = new Varien_Object();
     return $return->setDiscountInclTax($discountIncl)->setDiscountExclTax($discountExcl);
 }
开发者ID:AndreKlang,项目名称:Payex-Modules-Test,代码行数:47,代码来源:Discount.php

示例6: getInvoiceExtraPrintBlocksXML

 /**
  * Generate Invoice Print XML
  * @param Mage_Sales_Model_Order $order
  * @return mixed
  */
 public function getInvoiceExtraPrintBlocksXML($order)
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     $OnlineInvoice = $dom->createElement('OnlineInvoice');
     $dom->appendChild($OnlineInvoice);
     $OnlineInvoice->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $OnlineInvoice->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsd', 'http://www.w3.org/2001/XMLSchema');
     $OrderLines = $dom->createElement('OrderLines');
     $OnlineInvoice->appendChild($OrderLines);
     // Add Order Lines
     $items = $order->getAllVisibleItems();
     /** @var $item Mage_Sales_Model_Order_Item */
     foreach ($items as $item) {
         // @todo Calculate prices using Discount Rules
         // @todo Get children products from bundle
         //if (!$item->getNoDiscount()) {
         //    Mage::helper('partpayment/tools')->addToDebug('Warning: The product has a discount. There might be problems.', $order->getIncrementId());
         //}
         $itemQty = (int) $item->getQtyOrdered();
         //$taxPrice = $item->getTaxAmount();
         $taxPrice = $itemQty * $item->getPriceInclTax() - $itemQty * $item->getPrice();
         $taxPercent = $item->getTaxPercent();
         $priceWithTax = $itemQty * $item->getPriceInclTax();
         // Calculate tax percent for Bundle products
         if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
             $taxPercent = $taxPrice > 0 ? round(100 / (($priceWithTax - $taxPrice) / $taxPrice)) : 0;
         }
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', $item->getName()));
         $OrderLine->appendChild($dom->createElement('Qty', $itemQty));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $item->getPrice())));
         $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $taxPercent)));
         $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", $taxPrice)));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $priceWithTax)));
         $OrderLines->appendChild($OrderLine);
     }
     // Add Shipping Line
     if (!$order->getIsVirtual()) {
         $shipping = $order->getShippingAmount();
         //$shippingIncTax = $order->getShippingInclTax();
         $shippingTax = $order->getShippingTaxAmount();
         $shippingTaxPercent = $shipping != 0 ? (int) (100 * $shippingTax / $shipping) : 0;
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', $order->getShippingDescription()));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $shipping)));
         $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $shippingTaxPercent)));
         $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", $shippingTax)));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $shipping + $shippingTax)));
         $OrderLines->appendChild($OrderLine);
     }
     // add Payment Fee
     $fee = $order->getPartpaymentPaymentFee();
     if ($fee > 0) {
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', Mage::helper('partpayment')->__('Payment fee')));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $fee)));
         $OrderLine->appendChild($dom->createElement('VatRate', 0));
         $OrderLine->appendChild($dom->createElement('VatAmount', 0));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $fee)));
         $OrderLines->appendChild($OrderLine);
     }
     // add Discount
     $discount = $order->getDiscountAmount() + $order->getShippingDiscountAmount();
     if (abs($discount) > 0) {
         $discount_description = $order->getDiscountDescription() !== null ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount');
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', $discount_description));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $discount)));
         $OrderLine->appendChild($dom->createElement('VatRate', 0));
         $OrderLine->appendChild($dom->createElement('VatAmount', 0));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $discount)));
         $OrderLines->appendChild($OrderLine);
     }
     // Add reward points
     if ((double) $order->getBaseRewardCurrencyAmount() > 0) {
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', Mage::helper('partpayment')->__('Reward points')));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', -1 * $order->getBaseRewardCurrencyAmount()));
         $OrderLine->appendChild($dom->createElement('VatRate', 0));
         $OrderLine->appendChild($dom->createElement('VatAmount', 0));
         $OrderLine->appendChild($dom->createElement('Amount', -1 * $order->getBaseRewardCurrencyAmount()));
         $OrderLines->appendChild($OrderLine);
     }
     return str_replace("\n", '', $dom->saveXML());
 }
开发者ID:anziv,项目名称:Magento-modules,代码行数:94,代码来源:Order.php


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