Open
Description
Preconditions and environment
- Magento version 2.4.5-p3
- Cart consists only of virtual products (
is_virtual
is true) - Cart has coupon code applied
Steps to reproduce
- Create an empty cart
- Add virtual product to the cart
- Apply coupon code to cart
- Retrieve the cart with the applied discounts
query cart($cartId: String!) {
cart(cart_id: $cartId) {
is_virtual
prices {
discounts {
amount {
value
currency
}
label
}
}
applied_coupons {
code
}
}
}
Expected result
Coupon is applied to the cart and the applied discount is visible in the cart.prices.discounts
array.
{
is_virtual: true,
prices: {
discounts: [
{ amount: { value: 159.8, currency: 'EUR' }, label: '20% Discount' }
]
},
applied_coupons: [ { code: 'TEST-123' } ]
}
Actual result
Coupon code is applied and the discount is subtracted from the order total, however, the cart.prices.discounts
field is null
{
is_virtual: true,
prices: {
discounts: null
},
applied_coupons: [ { code: 'TEST-123' } ]
}
Additional information
The Discounts resolver attempts to read the discounts from the cart shipping address. Since it's a virtual cart, there is no shipping address and therefor no discounts will be returned.
Potential fix
Changing the line to $address = $quote->getBillingAddress();
will return the discounts as expected. But I am not sure if this will be 100% reliable.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.