0

Should be achieved by preference not using the plugin and observer. can anyone provide code for this ?

3
  • Using 'preference' should always be your last option, you should always choose plugin or observer as your first choice Commented Jun 30, 2022 at 11:57
  • This question is already answered. See magento.stackexchange.com/questions/357360/… Commented Jun 30, 2022 at 11:58
  • Okay @MagePal Extensions I think this is not right question that guy is new on magento exchange so accept solution . Can you describe code here ? Commented Jun 30, 2022 at 12:15

1 Answer 1

0

See Whenever a product is added to cart an additional qty of same product should be added to cart

Option 1 - (Don't recommend)

You can create a preference for

Magento\Checkout\Controller\Cart\Add and modify the execute method

Option 2 - (Strongly recommend)

Create a before plugin for

Magento\Checkout\Model\Cart\RequestQuantityProcessor::prepareQuantity

then check if the current request and update the qty as per your logic

1
  • Okay Thanks @MagePal Extensions Commented Jun 30, 2022 at 16:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.