woocommerce / woocommerce-gateway-paypal-express-checkout

58 stars 65 forks source link

Usage of "line_total" for coupons in `WC_Gateway_PPEC_Client::_get_rounded_total_in_order()` seems unnecessary #836

Open jorgeatorres opened 3 years ago

jorgeatorres commented 3 years ago

In #677, we introduced the following code as part of changes dealing with amount mismatch and discounts (see #485 for details):

https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout/blob/ed4161e96d7c139b1b331c4123f269c766acb1e8/includes/class-wc-gateway-ppec-client.php#L868-L872

While testing compatibility with PHP 8 I noticed that direct access to WC_Order_Item_Coupon is now deprecated, which results in deprecation warnings being logged:

[19-Nov-2020 16:28:26 UTC] The WC_Order_Item_Coupon::offsetGet function is deprecated since version 4.4.0.

I wanted to remove those warnings but then I realized this code doesn't seem to be doing much right now as "line_total" is not even set for coupon order items (i.e. it is null). As this doesn't seem to have an impact (and discounts/totals look fine on PayPal's side) It'd be good to confirm whether we even need this code anymore.

BrianHenryIE commented 3 years ago

FYI, we're getting those deprecation warnings on PHP 7.3.24 with WP_DEBUG enabled.