Php 8.2 WC_Cart_Fees_API bug
-
I was trouble shooting with WP_DEBUG on.
Issue:
Creation of dynamic property WC_Order_Item_Fee::$legacy_fee is deprecated in /plugins/woocommerce/includes/class-wc-checkout.php on line 568Creation of dynamic property WC_Order_Item_Fee::$legacy_fee_key is deprecated in /plugins/woocommerce/includes/class-wc-checkout.php on line 569
The deprecated warnings you’re seeing are related to the dynamic propertiesWC_Order_Item_Fee::$legacy_fee
andWC_Order_Item_Fee::$legacy_fee_key
, which are being triggered when adding fees during the checkout process in WooCommerce. These properties have been deprecated since WooCommerce 4.4.0.Particularly in the class
Orderable_Tip_Pro_Checkout
(class-tip-pro-checkout.php), the following actions likely trigger the deprecated properties:checkout_apply_tip()
andhandle_apply_tip_on_checkout_block()
: Both functions add fees usingWC()->cart->add_fee()
. This can cause the deprecated dynamic properties in WooCommerce to be created.update_percentage_tip()
: When recalculating percentage-based fees, it manipulates the fees usingWC()->cart->fees_api()->set_fees()
. This may also indirectly trigger the creation of the deprecated properties.
Solution: The plugin should update how it adds and manages fees to avoid triggering deprecated WooCommerce properties. Instead of using
WC()->cart->add_fee()
, the correct approach is to use theWC_Cart_Fees_API
class (WC()->cart->fees_api()
) to handle fee additions and updates. This will ensure compatibility with newer versions of WooCommerce and PHP.
- You must be logged in to reply to this topic.