1

必要なすべてのオプションが選択された、構成可能な製品の価格に価値を追加する方法を探しています。選択したシンプルな製品の完全な SKU と照合する必要があるため、オプションごとの価格が適切ではありません

SKU - 価格ペアを使用して JSON を作成しました。現在、タスクをきれいに実行し、カートへの追加およびチェックアウト段階で新しい価格を保持するための JS イベントを探しています。

洞察を事前にありがとう

4

1 に答える 1

4

オブザーバークラスを使用してリッスンしcheckout_cart_product_add_after、製品の「スーパーモード」を使用して見積もりアイテムに対してカスタム価格を設定できます。

/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にObserverクラスを作成します

class <namespace>_<modulename>_Model_Observer
{
    public function modifyPrice(Varien_Event_Observer $obs)
    {
        // Get the quote item
        $item = $obs->getQuoteItem();
        // Ensure we have the parent item, if it has one
        $item = ( $item->getParentItem() ? $item->getParentItem() : $item );
        // Load the custom price
        $price = $this->_getPriceByItem($item);
        // Set the custom price
        $item->setCustomPrice($price);
        $item->setOriginalCustomPrice($price);
        // Enable super mode on the product.
        $item->getProduct()->setIsSuperMode(true);
    }

    protected function _getPriceByItem(Mage_Sales_Model_Quote_Item $item)
    {
        $price;

        //use $item and maybe your json object to determine the correct price

        return $price;
    }

}

これは、バックエンドからの価格変更を処理します。javascriptについては、申し訳ありませんが、よくわかりません。

于 2012-03-29T23:22:19.160 に答える