のために事前にカートおよびチェックアウトの段階に
感謝を追加し、引用項目に対してカスタム価格を設定するために、製品の「スーパーモード」を使用します。あなたの/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>
そして/アプリ/コードでObserverクラスを作成/ローカル/ {名前空間}/{yourmodule} /Model/Observer.php
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については、申し訳ありませんが、わかりません!
私はJSの部分を実装することができたとして答えを受け入れました:) 匿名の顧客がカートに商品を追加して店にログインして価格を再計算する必要がある場合は、カスタム価格を更新します。これについてのアイデア? – Zifius
あなたはどのようにJSをやったのですか?あなたのソリューションが何であるかを知りたいと思っています。ログインの問題については、顧客がログインしたときに価格がリセットされていますか?おそらく、聞くべきより良いイベントがあるかもしれません。あるいは、ログインイベントを観察して各アイテムを反復することができます。 –
私は 'sales_quote_merge_after'イベントの価格問題を解決しました。これは、匿名の顧客カートがログインした顧客に変換された場所です。 JSについては、管理者の値ペアに対するオプションIDの完全なJSONを構築しました。完全なシンプルなSKUを収集し、最終的な価格に値を追加しました(再びJSONから) – Zifius