-
Notifications
You must be signed in to change notification settings - Fork 175
Description
What happened?
Description
Not sure if this is a bug or just changed in Craft Commerce 5.
But the qty in the populateLineItem event (https://craftcms.com/docs/commerce/5.x/extend/events.html#populatelineitem) is always 1.
We used the populateLineItem to calculate a new salePrice depending on how many items the customer bought.
Since updating from Craft 3 tot Craft 5 I've noticed that this new salePrice is wrong, so after a little investigating I found out that the qty in the event is always 1.
Probably because the default is set to 1: https://github.com/craftcms/commerce/blob/5.3.1/src/services/LineItems.php#L432
- And the new qty is never passed to this function as parameters in https://github.com/craftcms/commerce/blob/5.3.1/src/controllers/CartController.php#L172C72-L172C87
- Also see https://github.com/craftcms/commerce/blob/5.3.1/src/services/LineItems.php#L194
If this is just changed and not a bug anymore, which event do we need to use to calculate a new salePrice depending on custom Logic?
Steps to reproduce
- Add the populateLineItem in a module and log the qty.
- Add a product to the cart with qty higher then.
- The log shows that the qty is always 1, even when you add for example 5 products.
Expected behavior
The qty in the populateLineItem is greater then 1.
Actual behavior
The log shows that the qty is always 1, even when you add for example 5 products.
Craft CMS version
5.6.4
Craft Commerce version
5.3.1
PHP version
8.3
Operating system and version
Mac os
Database type and version
Mysql 8
Image driver and version
No response