• 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 568

    Creation 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 properties WC_Order_Item_Fee::$legacy_fee and WC_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() and handle_apply_tip_on_checkout_block(): Both functions add fees using WC()->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 using WC()->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 the WC_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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support kennethbryanlim

    (@kennethbryanlim)

    Hi @jpollie,

    Thank you for reaching out and bringing this to our attention.

    I will be forwarding this to our development team for further investigation, and we will get back to you once we have received any insights from them.

    Thank you!

    Hi @jpollie,

    Thanks for your patience!

    Just letting you know that our team is looking into this, so we can fix it in the following releases.

    Cheers!

    Hey @jpollie

    The deprecated warnings are due to WooCommerce moving away from dynamic properties. Instead of using WC()->cart->add_fee(), you should update your plugin to use WC()->cart->fees_api()->add_fee() from the WC_Cart_Fees_API class.

    Check your checkout_apply_tip() and handle_apply_tip_on_checkout_block() functions and refactor them to use the new API. Similarly, in update_percentage_tip(), ensure fee recalculations follow WooCommerce’s latest guidelines.

    Updating this should resolve the warnings and ensure future compatibility. 🚀

    Regards: Shehzam

    • This reply was modified 1 year, 1 month ago by shehzam2.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Php 8.2 WC_Cart_Fees_API bug’ is closed to new replies.