Automattic / woocommerce-subscriptions-core

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

WC_Subscription::set_status() is returning null #425

Closed csmcneill closed 1 year ago

csmcneill commented 1 year ago

The following was added in WooCommerce Subscriptions 4.7.0 (from the version history):

Introduce a WC_Subscription::set_status() function to handle subscriptions set with a draft or auto-draft status. Replaces the need for the overriding WC_Subscription::get_status() which has been deleted.

The user in 6170392-zen has custom code on their site where the set_status( method in WC_Subscription always returns null instead of the response from the parent set_status() method from the WC_Order class even though that method is called by the new one.

They'd like WC_Subscription::set_status() to return the same response as WC_Order::set_status() (which is an array), but WC_Subscription::set_status() is returning null.

They resolved this by updating the final line of the new set_status() function to:

return parent::set_status( $new_status, $note, $manual_update );

https://github.com/Automattic/woocommerce-subscriptions-core/pull/258#pullrequestreview-1183714309 seems to indicate that this might be expected, but it was suggested that an issue be created in p1680552859262189-slack-C7U3Y3VMY and p1680581731084739-slack-C02BW3Z8SHK