We have developed a custom module to add the additional options to the cart item using the observer events "checkout_cart_product_add_after" and "sales_model_service_quote_submit_before". It seems everything is working fine.
But, when we apply coupon code or enable gift options from the back-end or perform any default magento action l(like delete item, update item, etc) then new quote item id is being generated and old one has been removed. New one is being displayed without additional options we have added earlier.
This issue has been resolved in Magento 2.2 but can someone help us for version 2.1.*.
- Magento 2.1.7, PHP 7.0, Mysql 5.6
Preconditions
- Install Magento 2.1.9
- Create a product (simple/configurable)
- Add the product into the cart with some specific additional options. We have followed the steps from this https://webkul.com/blog/additional-options-cart-item-magento2/
Steps to Reproduce
- Apply coupon code from the cart page or enable gift options from global configuration on product level.
- Added additional options will be removed.
Expected result
- Data shouldn't be changed from the quote and added additional options should always be there.
Actual result
- https://drive.google.com/file/d/1Ds-JxlWostO9bU9PmLo6dKxvYUxvFR_Y/view
- https://drive.google.com/file/d/1px-YUpFrJtXpPcvjWPt8V5F06LDimoH6/view
Hopefully, you will get idea about the issue by above explanation. However, please let us know if you have any confusion.
Thank you in advance. Looking forward to hearing from you soon.