1

I have set custom product price using a controller and it works fine but when I go to cart page I see grand total not set to the zero.Because the summary section loads using the ajax after some time automatically.

I used this link in my controller :- I want to set custom price programmatically to the product Magento 2
Please see the screenshot I have attached below. first the order total and subtotal set to zero but after some time it loads automatically and set the price as default price.

foreach ($products_array as $value) 
{
    $params['qty'] = 1;//product quantity
    $_product = $this->productRepository->getById($value);
    $_product->setPrice(0);
    $_product->setBasePrice(0);
    $quote->addProduct($_product,$params); 
} 

enter image description here

enter image description here

enter image description here

  • You are adding product by using AddToCart button ? or directly by controller ? – Shashank Gupta Mar 22 '18 at 8:15
  • I used controller file, not AddToCart button. – Kushal Mar 22 '18 at 8:21
  • I used this question code in my controller magento.stackexchange.com/questions/216100/… – Kushal Mar 22 '18 at 8:21
  • I think The Summary Page is load using Knockout.js – Jaimin Mar 22 '18 at 8:58
  • @KushalDani - did you get the solution to your problem. if yes, plz share it. – Manashvi Birla Jul 11 '19 at 9:21

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.