Вы можете использовать класс наблюдателя, чтобы прослушать checkout_cart_product_add_after
, и использовать «Супер режим» продукта, чтобы установить пользовательские цены для элемента цитаты.
В вашем /app/code/local/ndomnamespace‹/ndomyourmoduleопроект/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 по адресу /app/code/local/ndomnamespace enj/ndomyourmodule coming/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, извините, но я не так уверен!