我是magento的初学者.我需要将动态价格从详细页面传递到购物车.
现在,当我通过动态价格时,它没有在购物车中更新,而是由产品的原始价格取代.
任何帮助将不胜感激.在这一行,我得到了价格.$price=$this->getRequest()->getParam('price_custom');
Indexcontroller.php
public function cartAction()
{
if ($this->getRequest()->getParam('cart')){
if ($this->getRequest()->getParam('cart') == "delete"){
$id = $this->getRequest()->getParam('id');
if ($id) {
try {
Mage::getSingleton('checkout/cart')->removeItem($id)
->save();
} catch (Exception $e) {
Mage::getSingleton('checkout/session')->addError($this->__('Cannot remove item'));
}
}
}
}
if ($this->getRequest()->getParam('product')) {
$cart = Mage::getSingleton('checkout/cart');
$params = $this->getRequest()->getParams();
$related = $this->getRequest()->getParam('related_product');
$price=$this->getRequest()->getParam('price_custom');
$productId = (int) $this->getRequest()->getParam('product');
if ($productId) {
$product = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
->load($productId);
try {
if (!isset($params['qty'])) {
$params['qty'] = 1;
}
$cart->addProduct($product, $params);
if (!empty($related)) {
$cart->addProductsByIds(explode(',', $related));
}
$cart->save(); …Run Code Online (Sandbox Code Playgroud)