Closed james-allan closed 3 years ago
I managed to find a fix for this. We just need to pass the subtotal (pre discount amount) when generating the product line item data.
eg
@@ -670,7 +670,7 @@ class WC_Payments_Subscription_Service {
'price_data' => $this->format_item_price_data(
$subscription->get_currency(),
$this->product_service->get_wcpay_product_id( $product ),
- $item->get_total() / $item->get_quantity(),
+ $item->get_subtotal() / $item->get_quantity(),
$subscription->get_billing_period(),
$subscription->get_billing_interval()
),
Describe the bug
Since we have moved to use price data for line items, taxes, fees, and shipping we no longer need to send coupons or discount data.
The reason for this is because we use the
$item->get_total()
to determine the price data amount, and the total is after discounts have been applied.We could use
$item->get_subtotal()
instead, however, that then throws out taxes because tax line items don't store subtotals (prediscount figures), it only stores the effective tax amount (the total).To Reproduce
Screenshots
Expected behavior
The totals should match.
Desktop (please complete the following information):
Smartphone (please complete the following information):