3

Steps to reproduce:

1.Please configure tax settings and tax rules as seen in screenshots.

2.Now login in storefront using Demo Customer Access provided by Magento 
  ([email protected]).

3.Please integrate the below code to apply custom price.

Observer :

namespace Vendor\MyModule\Observer;

use Magento\Framework\Event\ObserverInterface;

class BindPriceToCart implements ObserverInterface
{

public function execute(\Magento\Framework\Event\Observer $observer)
{   
        $price = 100;
        $event = $observer->getEvent();
        $item = $event->getQuoteItem();
        $item->setCustomPrice($price);
        $item->setOriginalCustomPrice($price);
        return $this;
}    

}

Event : checkout_cart_product_add_after

Configurations that needs to be set :

enter image description here enter image description here enter image description here enter image description here

Expected Result : enter image description here

Actual Result : enter image description here

3
  • did you try using another event? Or maybe a plugin. You could try the event sales_quote_item_set_product. I'm not saying it will work. I just wondering if using checkout_cart_product_add_after is not too late in the process to change the price.
    – Marius
    Jun 26, 2019 at 14:47
  • @Marius: I have tried "sales_quote_item_set_product" event but still facing the problem. Jun 27, 2019 at 5:28
  • If the custom_price and original_custom_price is set as NULL, once the product is added in cart, then calculation is seen fine on cart. May be magento team should empty the custom_price once the product is added in cart but not sure if it might have impact in other areas or not.. Jun 27, 2019 at 5:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.