Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong cart items total if promotion on units #11585

Closed
Roshyo opened this issue Jun 16, 2020 · 4 comments
Closed

Wrong cart items total if promotion on units #11585

Roshyo opened this issue Jun 16, 2020 · 4 comments
Labels
Bug Confirmed bugs or bugfixes.

Comments

@Roshyo
Copy link
Contributor

Roshyo commented Jun 16, 2020

Sylius version affected: 1.7 for sure, and I believe all previous as well

Description
We have a cart composed of 3 quantities of 1 product, $100 each.
If we apply a promotion of 100 split among those units, we will have

  • Unit1: 100 - 34
  • Unit2: 100 - 33
  • Unit3: 100 - 33

Everything is good from amount perspective, but in the cart summary, we end up having something like this :
image (11)

The Order total is right, but since each Beige Strappy summer dress costs $71.40, the items total is wrong.
In fact, those Beige Strappy summer dress costs $71.40, $71.39 and $71.39

Steps to reproduce
Apply a different promotion to first unit of an order item with multiple units and go to cart page.

Possible Solution
This has something to do with the way item total and itemsTotal are calculated.

@lchrusciel lchrusciel added the Potential Bug Potential bugs or bugfixes, that needs to be reproduced. label Jun 19, 2020
@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issues and PRs with no recent activity, about to be closed soon. label Sep 20, 2020
@Roshyo
Copy link
Contributor Author

Roshyo commented Sep 21, 2020

Do not stale please

@stale stale bot closed this as completed Oct 4, 2020
@GSadee GSadee reopened this Oct 6, 2020
@stale stale bot removed the Stale Issues and PRs with no recent activity, about to be closed soon. label Oct 6, 2020
@laurentdabbb
Copy link

laurentdabbb commented Dec 8, 2021

Hi,

Please consider this as a bug.

Bug is on the getSubtotal() method on OrderItem.
This method return $this->getDiscountedUnitPrice() * $this->quantity;

The problem is that getDiscountedUnitPrice() only retrieve discounted price from the first orderItem unit.

I encountered same issue with a new custom type of promotion "percentage discount on the Nth cheapest article".
This promotion allow to purpose promotion operations like "2+ 1 free".
With this promotion, I apply a 100% discount adjustment on cheapest unit. If this unit is the first unit of an orderItem, getSubtotal method return 0 whereas other units on this orderItem are not free...

Sylius version affected
I'm on 1.10.6

Possible solution
Do not use getDiscountedUnitPrice() in the getSubtotal() calculation

@lchrusciel lchrusciel added Bug Confirmed bugs or bugfixes. and removed Potential Bug Potential bugs or bugfixes, that needs to be reproduced. labels May 27, 2022
GSadee added a commit that referenced this issue Jun 22, 2022
This PR was merged into the 1.11 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.11
| Bug fix?        | yes                                                       |
| New feature?    | no                                                      |
| Related tickets | replace #13986, fixes #13532 and #11585                     |
| License         | MIT                                                          |

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->

We also should add here behat scenario, but TBH, I don't know how to prepare proper background

Commits
-------

37ab500 Calculate order item subtotal as the sum of units discounted price
b987eee Small refactor of orderItemSubTotal
@NoResponseMate
Copy link
Contributor

Hi @Roshyo

It seems the bug has been fixed in 1.11 via #14090
Let me know if that's not the case, but for now, I'm closing this issue.

Cheers 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

No branches or pull requests

5 participants