Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
87 stars 33 forks source link

Check if WooCommerce is older than 7.3 in `wcs_get_page_screen_id()`. #359

Closed shendy-a8c closed 1 year ago

shendy-a8c commented 1 year ago

Fixes #358

Description

We want wcs_get_page_screen_id( 'shop_subscription' ) to return 'shop_subscription' and since wc_get_page_screen_id() will do so since WC 7.3 (at least it still returns an empty string in 7.2.2), we should check wcs_is_woocommerce_pre( '7.3.0' ) instead of 6.9.0.

ps: I don't include changelog because this bug has not been released yet to public.

How to test this PR

  1. Install WC < 7.2.2.
  2. Create a new product (/wp-admin/post-new.php?post_type=product).
  3. You should not see a fatal error.

Product impact

james-allan commented 1 year ago

This looks good to me.

As the original author of the function wcs_get_page_screen_id() I was curious why the 6.9.0 check was failing. It turns out that although the function was introduced in 6.9.0, it wasn't until 7.3.0 that it could actually handle screen IDs other than shop_order.

For reference, here's the WC core PR https://github.com/woocommerce/woocommerce/pull/35658 and a link to specific changes.