Pricing display issues
There are some unique scenarios that require each line item to display their discount provided but the values may not match exactly. The reason is when a cart price rule discount is applied to multiple products but the values do not evenly divide into two decimal places.
Cart Price Rule = 10% discount applied to 2 products in the cart
Condition for price rule to take effect: total items in cart is 2
Actions apply percent of product price discount and that discount amount is 10
2 items are added to the cart, each are $19.95
To get the discount amount multiply the product price times 0.1
19.95 x 0.1 = 1.995
This is the issue, we have 3 decimal places, instead of two. Converting this to dollars is now a problem
The solution
Thinking about the website owner, who is the only person affected by this issue, it was determined that showing each item ordered with the discount provided in dollars was the most appropriate. To ensure that the entire order amount calculated properly, it was decided to round up the first item and the others drop the third decimal. Review this scenario:
Same 10% discount as above cart rule in effect
Add 2 products to the cart that are 19.95
Each product should get $1.995 in discounts
Product 1 - 19.95 x 0.1 = 1.995
2 - 19.95 x 0.1 = 1.995
A grand total of 3.99 is provided as a discount to the customer
When displaying the line items to the store owner in the admin,
we need to adjust the first item and round it up to 2.000. The second items we drop the third decimal
Product 1 = 2.00
Product 2 = 1.99
The total discount of the two products now when summed together match the actual discount provided to a customer.
Here is a screenshot as it would show in the admin for an order that has this scenario:
Other potential solutions and why they were not used
Same 10% discount as above cart rule in effect
Add 2 products to the cart that are 19.95
Each product should get $1.995 in discounts,
however if we just round them up, it shows too much discount.
Product 1 - 19.95 x 0.1 = 1.995
Product 2 - 19.95 x 0.1 = 1.995
Convert to round up all items
Product 1 New value is 2.00
Product 2 New value is 2.00
A grand total of 3.99 was actually provided as a discount to the customer,
however if we round up, it would show that $4.00 was given, and that is incorrect.
2.00 + 2.00 = $4.00
Similar issue if the third decimal was dropped for all items, it would show too little discount provided.
Same 10% discount as above cart rule in effect
Add 2 products to the cart that are 19.95
Each product should get $1.995 in discounts, however if we just drop the third decimal, this happens:
Product 1 - 19.95 x 0.1 = 1.995
Product 2 - 19.95 x 0.1 = 1.995
Convert to drop the third decimal for all items
Product 1 New value is 1.99
Product 2 New value is 1.99
A grand total of 3.99 was actually provided as a discount to the customer,
however if we drop the third decimal, it would show that $3.98 was given, and that is incorrect.
1.99 + 1.99 = $3.98
Additional resources
Commerce
- Commerce Tutorials
- Adobe Commerce Cloud
- Getting Started
- Global Reference Architecture
- Help and support
- Edge Delivery Services
- Webinars and events
- GraphQL and REST
- Adobe Developer App Builder
- Store Administration
- Customer Management
- Catalog Management
- Content Management
- Marketing Tools
- Orders and Fulfillment
- B2B for Adobe Commerce
- Tools and External services
- Commerce Intelligence
- Commerce Upgrades
- Back-end Development
- Native Front-end Luma Development
- Headless Architecture