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

[5.x]: Discount don't work if custom price calculation for lineItem #3896

Open
WHITE-developer opened this issue Feb 14, 2025 · 3 comments
Open

Comments

@WHITE-developer
Copy link

What happened?

Description

We have created a custom price calculation for a project, in where you can order a product (a fabric in this case) per meter. So in craft the variant has the price for 1m as the defaultPrice (say $20,-), and when people order this fabric, they fill in the amount of meters they want (for example 2m). Then the lineitem is saved as qty 1 and an option in where the length 2m is saved. We also calculate the price for this lineItem as 2 * the default price (2 * $20 = $40 in this case).

This works fine. But now our client has created a discount code, which only has to work if the total order amount is over $100,-.

And now it doesn't apply the discount, because i think it uses the purchasable price * the quantity.

For example, a customer has ordered 6m of the fabric and has a order of $120,- now. They should get the discount, because the order amount is over $100,-. But they discount isn't subtracted. Only when I add 6x 1m of this fabric in the cart, I get the discount.

Expected behavior

If i have a lineItem with the total price over the amount set in the discount, it should apply the discount

Actual behavior

Craft CMS version

5.5.7

Craft Commerce version

5.2.10

PHP version

8.3.8

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Copy link

linear bot commented Feb 14, 2025

@lukeholder
Copy link
Member

lukeholder commented Feb 17, 2025

@WHITE-developer Could you share the following (OR you can email this to [email protected] if you would prefer, just reference this issue number):

  • How are you doing the custom price calculation? Are you using an event?
  • Can you screenshot the discount rule? Is it based on the total item price or the total order price?

It might be easier to email us your database with the IDs of the cart affected, along with the product and discount IDs.

Let us know. Thanks!

@WHITE-developer
Copy link
Author

@lukeholder i've mailed your support.

@lukeholder lukeholder self-assigned this Feb 20, 2025
lukeholder added a commit that referenced this issue Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants