1

I have created an observer "checkout_cart_save_before" and plugin Addproduct.

It is working perfectly for the website but not triggering for API while hitting on the postman.

Any suggestions about how to make this work.

Any help would be appreciated.

0

The event checkout_cart_save_before is only fire maegnto frontent.

You can use sales_quote_product_add_after event which is for all area Frontend,Admin,Rest Api,Rest Soap.

$this->_eventManager->dispatch('sales_quote_product_add_after', ['items' => $items]);

See the class \Magento\Quote\Model\Quote::addProduct

| improve this answer | |
  • Thanks Amit, working on it – Amy Jun 23 at 15:08
  • Hi Amit, I am not able to get the current customer quote item while hitting from rest API. Could you please help me with this. – Amy Jun 29 at 4:55
  • You donot get customer in response of API and which API you are using? – Amit Bera Jun 29 at 5:33
  • Hi Amit, I am using addproduct API (POST <host>/rest/default/V1/products). Here want I am trying to achieve is while adding product I am clearing the existing customer cart item, for this I am using class \Magento\Quote\Model\Quote::addProduct (around plugin) – Amy Jun 30 at 12:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.