小编Nag*_*ani的帖子

将详细页面中的动态价格传递给magento中的购物车

我是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)

shopping-cart dynamic magento cart

2
推荐指数
1
解决办法
2093
查看次数

标签 统计

cart ×1

dynamic ×1

magento ×1

shopping-cart ×1