第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在將產(chǎn)品添加到購物車時(shí)更改報(bào)價(jià)的價(jià)格:magento

在將產(chǎn)品添加到購物車時(shí)更改報(bào)價(jià)的價(jià)格:magento

哈士奇WWW 2019-12-03 10:48:48
我想在將產(chǎn)品添加到購物車時(shí)更改產(chǎn)品價(jià)格。怎么可能讓我知道...
查看完整描述

3 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊

做到這一點(diǎn)的方法是添加一個(gè)觀察該事件的觀察者'sales_quote_add_item':


<events>

    <sales_quote_add_item>

        <observers>

            <priceupdate_observer>

                <type>singleton</type>

                <class>mymodule/observer</class>

                <method>updatePrice</method>

            </priceupdate_observer>

        </observers>

    </sales_quote_add_item>

</events>

觀察者應(yīng)具有執(zhí)行以下操作的方法:


public function updatePrice($observer) {

    $event = $observer->getEvent();

    $quote_item = $event->getQuoteItem();

    $new_price = <insert logic>

    $quote_item->setOriginalCustomPrice($new_price);

    $quote_item->save();

}


查看完整回答
反對(duì) 回復(fù) 2019-12-03
?
30秒到達(dá)戰(zhàn)場

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個(gè)贊

您可以使用觀察者類來收聽checkout_cart_product_add_after,并使用產(chǎn)品的“超級(jí)模式”為報(bào)價(jià)項(xiàng)設(shè)置自定義價(jià)格。


在您的/app/code/local/{namespace}/{yourmodule}/etc/config.xml中:


<config>

    ...

    <frontend>

        ...

        <events>

            <checkout_cart_product_add_after>

                <observers>

                    <unique_event_name>

                        <class>{{modulename}}/observer</class>

                        <method>modifyPrice</method>

                    </unique_event_name>

                </observers>

            </checkout_cart_product_add_after>

        </events>

        ...

    </frontend>

    ...

</config>

然后在/app/code/local/{namespace}/{yourmodule}/Model/Observer.php中創(chuàng)建一個(gè)Observer類


    <?php

        class <namespace>_<modulename>_Model_Observer

        {

            public function modifyPrice(Varien_Event_Observer $obs)

            {

                $customPrice = Mage::getSingleton(’core/session’)->getCustomPriceCalcuation(); // Provide you price i have set with session

                $p = $obs->getQuoteItem();

                $p->setCustomPrice($customPrice)->setOriginalCustomPrice($customPrice); 

            }


        }


查看完整回答
反對(duì) 回復(fù) 2019-12-03
?
慕田峪4524236

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊

堅(jiān)果湯。


文件:/app/etc/modules/config.xml


<?xml version="1.0" encoding="UTF-8"?>

<config>

  <modules>

    <Ajax_ProductAdjust>

      <codePool>local</codePool>

      <active>true</active>

    </Ajax_ProductAdjust>

  </modules>

</config>

文件:/app/code/local/Ajax/ProductAdjust/etc/config.xml


<?xml version="1.0"?>

      <config>

       <modules>

         <Ajax_ProductAdjust>

           <version>1.0.1</version>

         </Ajax_ProductAdjust>

       </modules>

       <global>

           <models>

             <Ajax_ProductAdjust>

               <class>Ajax_ProductAdjust_Model</class>

             </Ajax_ProductAdjust>

           </models>

           <events>

              <sales_quote_add_item>

                  <observers>

                     <ajax_productadjust_model_observer>

                        <type>singleton</type>

                        <class>Ajax_ProductAdjust_Model_Observer</class>

                        <method>updatePrice</method>

                     </ajax_productadjust_model_observer>

                 </observers>

              </sales_quote_add_item>

          </events>

      </global>

     </config>

文件:/app/code/local/Ajax/ProductAdjust/Model/Observer.php


<?php

//Notes

class Ajax_ProductAdjust_Model_Observer

{


    public function _construct()

      {

      }


    public function getNewPrice()

      {

        //Your new functionality here

        //

        $newprice = "";


        return $newprice;

      }


     public function updatePrice( Varien_Event_Observer $observer ) 

     {

        $event = $observer->getEvent();

        $quote_item = $event->getQuoteItem();

        $new_price = $this->getNewPrice();

        $quote_item->setOriginalCustomPrice($new_price);

        $quote_item->save();

      }

 }

干杯,


查看完整回答
反對(duì) 回復(fù) 2019-12-03
  • 3 回答
  • 0 關(guān)注
  • 780 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)