magento如何在结帐页面中更改购物车帐户

magento如何在结帐页面中更改购物车帐户,magento,Magento,在产品详细信息页面中,产品价格为50美元,我使用JavaScript将价格更改为80美元,但当添加到购物车时,在结帐页面中仍然是50美元。如何让它在结帐页面中仍然是80美元?您需要使用“销售报价添加项目”magento事件在购物车会话中更新产品价格。 您必须为此制作一个自定义模块 在app/etc/modules/Company_All.xml中创建一个文件 <?xml version="1.0"?> <config> <modules> <

在产品详细信息页面中,产品价格为50美元,我使用JavaScript将价格更改为80美元,但当添加到购物车时,在结帐页面中仍然是50美元。如何让它在结帐页面中仍然是80美元?

您需要使用“销售报价添加项目”magento事件在购物车会话中更新产品价格。 您必须为此制作一个自定义模块

在app/etc/modules/Company_All.xml中创建一个文件

<?xml version="1.0"?> <config>   <modules>
    <Company_Product>
      <codePool>local</codePool>
      <active>true</active>
    </Company_Product>   </modules> </config>
<?xml version="1.0"?> <config>   <global>
    <models>
        <product>
             <class>Company_Product_Model</class>
        </product>
    </models>
    <events>
      <sales_quote_add_item><!--Event to override price after adding product to cart-->
        <observers>
          <company_product_price_observer><!--Any unique identifier name -->
            <type>singleton</type>
            <class>Company_Product_Model_Price_Observer</class><!--Our observer class name-->
            <method>update_book_price</method><!--Method to be called from our observer class-->
          </company_product_price_observer>
        </observers>
      </sales_quote_add_item>
    </events>   </global> </config>
class Company_Product_Model_Price_Observer{
    public function update_book_price(Varien_Event_Observer $observer) {
        $quote_item = $observer->getQuoteItem();

        //if(){ //your logic goes here
            $customprice = 50;
        //}
        $quote_item->setOriginalCustomPrice($customprice);
        $quote_item->save();
        return $this;
    }

}