2

構成.xml

        <sales_quote_collect_totals_before>
            <observers>
                <discount>
                    <class>discount/observer</class>
                    <method>discountMethod</method>
                </discount>
            </observers>
        </sales_quote_collect_totals_before>

Observer.php

public function discountMethod($observer)
{
   $quote = $observer->getEvent()->getQuote();
   $quote->setGrandTotal(1);
   $quote->setBaseGrandTotal(1);
   $quote->save();
}

既に config.xml と Observer.php を作成しましたが、そのコードはまったく機能しません。$quote->getData() は以下を示します:

[grand_total] => 1
[base_grand_total] => 1

しかし、ページのGrandTotalにはまだ真の価格が表示されています 総計

デフォルトの Magento 1.6.2を使用しています。checkout/onepage/indexでは、[続行]をクリックするたびに関数がトリガーされますが、見積もり時に grandTotal / BaseGrandTotal を設定する方法がわかりません。

4

1 に答える 1

4

を聞いてsales_quote_collect_totals_beforeいるので、このイベントの後に を含む合計grandTotalが収集され、grandTotal実行時に合計コレクターが 0 にリセットされます。

代わりに使用している場合sales_quote_collect_totals_after、合計は正しいはずですが、古い合計に基づいているため、税金の計算が台無しになります。

私が考えることができる唯一のクリーンな方法は、独自のトータルコレクターを作成することです<before>tax</before>

新しい合計コレクターを作成する方法に関するリンクは次のとおりです: http://magento.ikantam.com/qa/how-add-discount-total-magento

それが役立つことを願っています

于 2013-10-03T21:47:04.000 に答える