1

I am stuck on the one problem,I have added one product with custom price in cart using custom-module controller.Product is adding with the custom price but the summary section subtotal and grandtotal is not updating.

Please suggest how can i refresh the summary section in the cart page.

$params = array(
            'product' => $productId,
            'super_attribute' => $options,
            'qty' => $qty,
        );

        $_product = $this->_productRepository->getById($productId);
        $_product->setPrice($price);
        $_product->setBasePrice($price);
        $_product->setRowTotal($price);
        $_product->setBaseRowTotal($price);
        $_product->setOriginalCustomPrice($price);
        $_product->setPriceInclTax($price);
        $_product->setBasePriceInclTax($price);
        $_product->setRowTotalInclTax($price);
        $_product->setBaseRowTotalInclTax($price);
        $this->_cart->addProduct($_product,$params);
        $this->_cart->save();
        $this->_cart->getQuote()->setTotalsCollectedFlag(false);
        $this->_cart->getQuote()->collectTotals();
        $this->_cart->getQuote()->save(); 
        $this->_checkoutquote->setTotalsCollectedFlag(false)->collectTotals()->save();
        $this->_session->getQuote()->collectTotals()->save();
        $this->quoteRepository->get($this->_session->getQuoteId());
        $quote = $this->_session->getQuote();
        $this->quoteRepository->save($quote->collectTotals());
  • show you controller code for set product custom price. – Suresh Chikani Feb 2 '18 at 18:25
  • @SureshChikani ,Thanks for the quick response.I can share the code in morning.As i was stuck in this problem so thought to get the answer from stack exchange.Will share when will join office tomorrow.BTW adding programatically with help of cart model addproduct function. – OMG Feb 2 '18 at 18:27
  • @SureshChikani kindly check my code .Any quick help will be appreciated – OMG Feb 3 '18 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.