Product Bundles 7.0.0, Composite Products 9.0.0 and All Products for Woo Subscriptions 5.0.0 Updates – Adding PHP 8.3 Support and Properties Controller Changes

Product Bundles 7.0.0, Composite Products 9.0.0 and All Products for Woo Subscriptions 5.0.0 will be released on March 5th, 2024. These updates make all three extensions compatible with PHP 8.3, but include a change in how product properties are handled that third-party developers should be aware of.

Release Notes

Introducing PHP 8.3 Compatibility

These new versions make Product Bundles, Composite Products and All Products for Woo Subscriptions compatible with PHP 8.3 by:

  • resolving all PHP 8.3 notices,
  • properly declaring class properties that were previously not declared and;
  • using the new controller to handle (set, get, delete) properties on WooCommerce Core objects that were previously dynamically declared. You can learn more about this change below.

For Product Bundles, the new controller is: WC_PB_Product_Data.

For Composite Products, the new controller is: WC_CP_Product_Data.

For All Products for Woo Subscriptions, the new controller is: WCS_ATT_Product_Data.

Impact

Update Requirement

If you’re a merchant who uses Product Bundles, Composite Products and All Products for Woo Subscriptions together, all must be updated for full compatibility. For example, if you update Composite Products to 9.0.0, you must also update Product Bundles to 7.0.0 (and vice-versa). Only updating one of the three extensions may result in unexpected behavior due to incompatibility.

Additionally, to continue using Product Add-Ons with Product Bundles 7.0.0, Composite Products 9.0.0 or All Products for Woo Subscriptions 5.0.0 you must update Product Add-Ons to v6.7.0.

Extension Developers: Supporting these Updates

The way in which developers should interact with properties has changed in these updates. You should make use of the new product data controllers depending on the plugin you are integrating with.

Here’s how you could use the controller to get, set and delete the composited_weight property using the Composite Products product data controller as an example:

  • Getting a property:
    WC_CP()->product_data->get( $product, 'composited_weight' );
  • Setting a property:
    WC_CP()->product_data->set( $product, 'composited_weight', $value );
  • Unsetting a property:
    WC_CP()->product_data->delete( $product, 'composited_weight' );

In these examples, $product is the object that holds or will be associated with the property, and $value is the property’s value.

When updating your extension to add compatibility for this update, here’s what some of the changes may look like (the following example uses a Product Bundles property and a Product Bundles data controller):

  • Getting a property: $value = $product->bundled_item_price; would become
    WC_PB()->product_data->get( $product, 'bundled_item_price' );
  • Setting a property: $product->bundled_item_price = $value; would become
    WC_PB()->product_data->set( $product, 'bundled_item_price', $value );
  • Unsetting a property: unset( $product->bundled_item_price); would become
    WC_PB()->product_data->delete( $product, 'bundled_item_price' );

The properties that were previously dynamically declared and therefore should make use of this controller are:

  • In Composite Products: composited_weight, composited_value, child_subtotals_added, composite_needs_processing, composited_cart_item, is_filtered_price_html, composited_price_offset, composited_price_offset_pct, wc_mmq_composited_item, container_quantity.
  • In Product Bundles: bundled_cart_item, block_subscription, bundled_weight, bundled_value, child_subtotals_added, bundle_needs_processing, bundled_price_offset, bundled_price_offset_pct, bundled_item_pricewc_mmq_bundled_item, container_quantity.
  • In All Products for Woo Subscriptions: wcsatt_instance, wcsatt_bypass_switch_filter.

If you’re unable to make these changes, we recommend throwing a compatibility notice that your extension isn’t compatible with Product Bundles 7.0.0, Composite Products 9.0.0 or All Products for Woo Subscriptions 5.0.0.

Thank you!

Thanks for building on Woo! We appreciate you!

If you have any questions or feedback about these updates, we recommend joining our community Slack and sharing them there. If you run into any issues with these updates, please report them through your Woo.com account and create a ticket and select the product from the product dropdown on that page.


6 responses to “Product Bundles 7.0.0, Composite Products 9.0.0 and All Products for Woo Subscriptions 5.0.0 Updates – Adding PHP 8.3 Support and Properties Controller Changes”

  1. Hi Jacklyn,

    So basically you are telling us that, next week, these 3 addons will have breaking changes and if 3rd party developers don’t have time to make the required adjustments until next week, they should just release a patch version throwing a forward-incompatible notice.

    Is that correct?

    1. Jacklyn Biggin Avatar
      Jacklyn Biggin

      Hey Pierre! Yes, that’s the approach that was recommended to me by the team working on this update. To be clear, not every extension that is compatible with these three extensions will be affected by this change. The only extensions that should be impacted are ones that access/modify the WooCommerce Core objects mentioned in this article.

  2. Hi all. I am looking at needing to do something similar for Mix and Match Products and Free Gift Coupons… both of which need a dynamic product property.

    I’ve been following along with the work on Product Bundles to solve this PHP 8.3 compat issue and it’s great work. But last week I was wondering if we could push for some kind of system IN woo core. You duplicated a lot of work across multiple plugins and I am going to have to duplicate it across 2 (and for Free Gift Coupons I don’t have a custom product type so this still won’t work well). And we can’t be the only ones who need this. Wouldn’t it be better to have a central option in core?

    Could we do something almost identical to how `set|get_meta_data()` works or `set|get_prop()`, but with nothing tied to the save routine. Suggestions could be `set|get_dynamic_data()` or `set|get_dynamic_prop()`

    Technically there would be a gap for folks who are on PHP8.3 but on an older version of Woo that doesn’t have the new addition. But it’s still early enough I think that’s fairly minimal.. and also fixable with an update once/if we add this.

    This solves the PHP8.3 compatibility problem across all plugins in a standardized, predictable, way. I think that would be a net win.

    1. shanibanerjee Avatar
      shanibanerjee

      Hi Kathy,

      While we don’t currently have plans to introduce magic setters/getters for dynamic property declaration on the product. That said, the core team believes this is an opportunity for a public discussion to hammer out the pros and cons. The opportunity here might be to bring this up in GitHub Discussions, or in the #monorepo channel in the community slack for weigh in from our core developers.

      1. Hi Shani, I am not thinking magic settings… I am thinking defining an object property and then a getter and setter to add key/value pairs. Almost identical to how `get|set_prop()` works. I have opened an issue at GH for discussion.

        https://github.com/woocommerce/woocommerce/issues/45286

        1. shanibanerjee Avatar
          shanibanerjee

          Thanks for the clarification – I’ll send this to the devs to weigh in.

Leave a Reply

Your email address will not be published. Required fields are marked *