Skip to content

Commit

Permalink
Change the filter hook from post_updated_messages to woocommerce_orde… (
Browse files Browse the repository at this point in the history
#615)

* Change the filter hook from post_updated_messages to woocommerce_order_updated_messages to show the subscription updated message in subscription-edition screen

* Update post_updated_messages to work when HPOS is enabled and disabled

* Add changelog entry

---------

Co-authored-by: mattallan <[email protected]>
  • Loading branch information
nikhiltechahead and mattallan authored May 9, 2024
1 parent 79fca67 commit befb215
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Fix - Ensure the scheduled sale price for subscription products ends at the end of the "to" day set in product settings.
* Fix - Subscription table is empty in mobile view when HPOS is enabled.
* Fix - WooCommerce page header is hidden when HPOS is enabled.
* Fix - Subscription updated messages missing on the Edit Subscription page when HPOS is enabled.
* Fix - Resolved an issue that prevented bulk actions from running on the Subscriptions list table when the table was filtered by date, payment method, product or customer.
* Dev - Calling wcs_create_subscription() will no longer attempt to fetch a fresh instance of the subscription at the end. This is to prevent loading the subscription from the database potentially unnecessarily.

Expand Down
7 changes: 5 additions & 2 deletions includes/admin/class-wcs-admin-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function __construct() {
add_action( 'parse_query', array( $this, 'shop_subscription_search_custom_fields' ) );

add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
add_filter( 'woocommerce_order_updated_messages', array( $this, 'post_updated_messages' ) );

// Add ListTable filters when CPT is enabled
add_action( 'restrict_manage_posts', array( $this, 'restrict_by_product' ) );
Expand Down Expand Up @@ -1095,7 +1096,9 @@ public static function set_post__in_query_var( $query_vars, $post_ids ) {
* @return array
*/
public function post_updated_messages( $messages ) {
global $post, $post_ID;
global $post, $theorder;

$created_date = ! empty( $theorder ) && $theorder instanceof WC_Subscription ? $theorder->get_date_created() : $post->post_date;

$messages['shop_subscription'] = array(
0 => '', // Unused. Messages start at index 1.
Expand All @@ -1109,7 +1112,7 @@ public function post_updated_messages( $messages ) {
7 => __( 'Subscription saved.', 'woocommerce-subscriptions' ),
8 => __( 'Subscription submitted.', 'woocommerce-subscriptions' ),
// translators: php date string
9 => sprintf( __( 'Subscription scheduled for: %1$s.', 'woocommerce-subscriptions' ), '<strong>' . date_i18n( _x( 'M j, Y @ G:i', 'used in "Subscription scheduled for <date>"', 'woocommerce-subscriptions' ), wcs_date_to_time( $post->post_date ) ) . '</strong>' ),
9 => sprintf( __( 'Subscription scheduled for: %1$s.', 'woocommerce-subscriptions' ), '<strong>' . date_i18n( _x( 'M j, Y @ G:i', 'used in "Subscription scheduled for <date>"', 'woocommerce-subscriptions' ), wcs_date_to_time( $created_date ) ) . '</strong>' ),
10 => __( 'Subscription draft updated.', 'woocommerce-subscriptions' ),
);

Expand Down

0 comments on commit befb215

Please sign in to comment.