WooCommerce REST API using deprecated code
-
Built-in WooCommerce REST API code is using a deprecated accessor and needs to be updated.
In /woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php
Around like 324, change FROM:
'code' => $coupon_item['name'], 'discount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ), 'discount_tax' => wc_format_decimal( $coupon_item['discount_amount_tax'], $dp ),Change TO:
'code' => $coupon_item->get_name(), 'discount' => wc_format_decimal( $coupon_item->get_discount(), $dp ), 'discount_tax' => wc_format_decimal( $coupon_item->get_discount_tax(), $dp ),The name, discount amount, and discount amount tax should not be accessed using the array parameters, but rather with getters.
This will remove the deprecation warning when accessing coupon information in REST API v1.
Thank you!
Kevin
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘WooCommerce REST API using deprecated code’ is closed to new replies.