當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Varien_Event::getOrder方法代碼示例

本文整理匯總了PHP中Varien_Event::getOrder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event::getOrder方法的具體用法?PHP Varien_Event::getOrder怎麽用?PHP Varien_Event::getOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Varien_Event的用法示例。


在下文中一共展示了Varien_Event::getOrder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setOrderCurrency

 /**
  * handles the event checkout_type_onepage_save_order to set the currency of the order
  * @param Varien_Event $event
  */
 public function setOrderCurrency($event)
 {
     if (Mage::helper('imagecc')->isActive()) {
         $order = $event->getOrder();
         if ($order && !Mage::helper('imagecc')->isPaypalOrder($order)) {
             if ($this->_useFixedCurrency($order)) {
                 return;
             }
             Mage::helper('imagecc')->log("Using display currency " . $order->getIncrementId());
             $imagecc_preserved_information = array('order_fields' => array(), 'item_fields' => array());
             $_coreHelper = Mage::helper('core');
             foreach ($this->_orderFields as $field) {
                 $field2 = preg_replace('(^base_)', '', $field);
                 $new_v = $order->getData($field2);
                 //$v = $order->getData($field);
                 //$new_v = $_coreHelper->currency($v, false, false);
                 /**
                  * preserve information before change it
                  */
                 if ($field !== $field2) {
                     $imagecc_preserved_information['order_fields'][] = array('field' => $field, 'original_value' => $order->getData($field), 'new_value' => $new_v);
                 }
                 $order->setData($field, $new_v);
                 Mage::helper('imagecc')->log("{$field2} {$field} {$new_v}");
             }
             foreach ($order->getAllItems() as $item) {
                 $arr = $this->_itemFields;
                 $quoteItemId = $item->getData('quote_item_id');
                 $imagecc_preserved_information['item_fields'][$quoteItemId] = array();
                 foreach ($arr as $k) {
                     //$v = $item->getData($k);
                     //$new_v = $_coreHelper->currency($v, false, false);
                     $field2 = preg_replace('(^base_)', '', $k);
                     $new_v = $item->getData($field2);
                     /**
                      * preserve information before change it
                      */
                     if ($k !== $field2) {
                         $imagecc_preserved_information['item_fields'][$quoteItemId][] = array('field' => $k, 'original_value' => $item->getData($k), 'new_value' => $new_v);
                     }
                     $item->setData($k, $new_v);
                     Mage::helper('imagecc')->log("{$field2} {$k} {$new_v}");
                 }
                 //$item->save();
             }
             $store_currency = $order->getData('order_currency_code');
             /**
              * preserve information before change it
              */
             $imagecc_preserved_information['order_fields']['global_currency_code'] = array('original_value' => $order->getData('global_currency_code'), 'field' => 'global_currency_code', 'new_value' => '');
             $imagecc_preserved_information['order_fields']['base_currency_code'] = array('original_value' => $order->getData('base_currency_code'), 'field' => 'base_currency_code', 'new_value' => '');
             $imagecc_preserved_information['order_fields']['store_currency_code'] = array('original_value' => $order->getData('store_currency_code'), 'field' => 'store_currency_code', 'new_value' => '');
             $order->setData('global_currency_code', $store_currency)->setData('base_currency_code', $store_currency)->setData('store_currency_code', $store_currency)->setData('imagecc_preserved_information', json_encode($imagecc_preserved_information));
         }
     }
 }
開發者ID:vinayshuklasourcefuse,項目名稱:sareez,代碼行數:60,代碼來源:Intellimage_CurrencyCheckout_Model_Observer.php


注:本文中的Varien_Event::getOrder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。