magento2: A catalog price rule doesn't save the discount in sales_order_item
Preconditions (*)
- Magento 2.3.* and 2.2.*.
- Catalog price rule which is enabled.
- A visible and enabled product.
Steps to reproduce (*)
- Create a product with the sku ‘A’.
- Create a catalog price rule for the product with the sku ‘A’ with a percentage discount or a fixed discount.
- Apply and save the catalog price rule.
- Run the command
bin/magento index:reindex
. - Place the product with the sku ‘A’ in your cart.
- Complete the checkout process.
Expected result (*)
- Product ‘A’ is shown with the discounted price on the product detail page and in the checkout [frontend].
- In the backoffice the discounted amount/percentage is shown in the order per order item [backend].
- In the table
sales_order_item
thediscount_amount
ordiscount_percent
value is saved [database].
Actual result (*)
- Product ‘A’ is shown with the discounted price on the product detail page and in the checkout [frontend].
- In the backoffice the discounted amount/percentage is NOT shown in the order at all [backend].
- In the table
sales_order_item
thediscount_amount
ordiscount_percent
value is NOT saved [database].
At the moment there is no proper way to ascertain whether an order item actually has a discount or not.
The applied_rule_ids
does not necessarily mean it is a discount for the product, it could also be free shipping for example.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 21 (17 by maintainers)
I’m reopening this issue, because this issue has not been resolved. The issue has been reproduced and is acknowledged, so this behaviour is not as expected.
Also, it doesn’t matter whether the discount is applied with a catalog price rule or a cart price rule. Both are discounts and you want to register to the total amount of discount given. In the current situation you can’t see the original price of the item when a catalog price rule is being used, so that valuable data is being lost. This will also mess up reports in Magento if you want to see how much discount has been given, because it will only calculate discounts from cart price rules.
Either way, a special price or a price different then the original price is a discount, and it shouldn’t matter where this discount is applied. It could be applied in the catalog or it could be applied in the cart, you’re giving a discount on the price of the product. This should be registered as a discount.