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


PHP Mage_Sales_Model_Order_Item::setPrice方法代码示例

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


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

示例1: _writeOrderItem

 protected function _writeOrderItem(Mage_Sales_Model_Order_Item $item, XMLWriter $xml, $storeId = null)
 {
     // inherit some attributes from parent order item
     if ($item->getParentItemId() && !$item->getParentItem()) {
         $item->setParentItem(Mage::getModel('sales/order_item')->load($item->getParentItemId()));
     }
     // only inherit if parent has been hidden
     if ($item->getParentItem() && $item->getPrice() == 0.0 && Mage::helper('auctaneapi')->isExcludedProductType($item->getParentItem()->getProductType())) {
         $item->setPrice($item->getParentItem()->getPrice());
     }
     /* @var $gift Mage_GiftMessage_Model_Message */
     $gift = Mage::helper('giftmessage/message')->getGiftMessage(!$item->getGiftMessageId() && $item->getParentItem() ? $item->getParentItem()->getGiftMessageId() : $item->getGiftMessageId());
     $item->setGift($gift->isObjectNew() ? 'false' : 'true');
     if (!$gift->isObjectNew()) {
         $item->setGiftMessage(sprintf("From: %s\nTo: %s\nMessage: %s", $gift->getSender(), $gift->getRecipient(), $gift->getMessage()));
     }
     /* @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getProductId());
     // inherit some attributes from parent product item
     if ($parentProduct = $this->_getOrderItemParentProduct($item, $storeId)) {
         if (!$product->getImage() || $product->getImage() == 'no_selection') {
             $product->setImage($parentProduct->getImage());
         }
         if (!$product->getSmallImage() || $product->getSmallImage() == 'no_selection') {
             $product->setSmallImage($parentProduct->getSmallImage());
         }
         if (!$product->getThumbnail() || $product->getThumbnail() == 'no_selection') {
             $product->setThumbnail($parentProduct->getThumbnail());
         }
     }
     $xml->startElement('Item');
     $helper = Mage::helper('auctaneapi');
     if (Mage::helper('auctaneapi')->getExportPriceType($item->getOrder()->getStoreId()) == Auctane_Api_Model_System_Source_Config_Prices::BASE_PRICE) {
         $helper->fieldsetToXml('base_sales_order_item', $item, $xml);
     } else {
         $helper->fieldsetToXml('sales_order_item', $item, $xml);
     }
     /* using emulation so that product images come from the correct store */
     $appEmulation = Mage::getSingleton('core/app_emulation');
     $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($product->getStoreId());
     Mage::helper('auctaneapi')->fieldsetToXml('sales_order_item_product', $product, $xml);
     $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
     $xml->startElement('Options');
     $this->_writeOrderProductAttribute($product, $xml, $storeId);
     // items may have several custom options chosen by customer
     foreach ((array) $item->getProductOptionByCode('options') as $option) {
         $this->_writeOrderItemOption($option, $xml, $storeId);
     }
     $buyRequest = $item->getProductOptionByCode('info_buyRequest');
     if ($buyRequest && @$buyRequest['super_attribute']) {
         // super_attribute is non-null and non-empty, there must be a Configurable involved
         $parentItem = $this->_getOrderItemParent($item);
         /* export configurable custom options as they are stored in parent */
         foreach ((array) $parentItem->getProductOptionByCode('options') as $option) {
             $this->_writeOrderItemOption($option, $xml, $storeId);
         }
         foreach ((array) $parentItem->getProductOptionByCode('attributes_info') as $option) {
             $this->_writeOrderItemOption($option, $xml, $storeId);
         }
     }
     $xml->endElement();
     // Options
     $xml->endElement();
     // Item
 }
开发者ID:xiaoguizhidao,项目名称:bb,代码行数:65,代码来源:Export.php

示例2: _correctPrices

 /**
  * Set correct item prices ((original price / new qty) * old qty)
  *
  * @param Mage_Sales_Model_Order_Item $orderItem
  * @param int $oldQty
  * @param int $newQty
  * @return Mage_Sales_Model_Order_Item
  */
 protected function _correctPrices($orderItem, $oldQty, $newQty)
 {
     $orderItem->setPrice($orderItem->getPrice() / $newQty * $oldQty);
     $orderItem->setBasePrice($orderItem->getBasePrice() / $newQty * $oldQty);
     $orderItem->setOriginalPrice($orderItem->getOriginalPrice() / $newQty * $oldQty);
     $orderItem->setBaseOriginalPrice($orderItem->getBaseOriginalPrice() / $newQty * $oldQty);
     $orderItem->setPriceInclTax($orderItem->getPriceInclTax() / $newQty * $oldQty);
     $orderItem->setBasePriceInclTax($orderItem->getBasePriceInclTax() / $newQty * $oldQty);
     return $orderItem;
 }
开发者ID:sandermangel,项目名称:adyen-magento-subscription,代码行数:18,代码来源:Observer.php


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