Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit befb215

Browse files
nikhiltechaheadmattallan
andauthored
Change the filter hook from post_updated_messages to woocommerce_orde… (#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]>
1 parent 79fca67 commit befb215

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Fix - Ensure the scheduled sale price for subscription products ends at the end of the "to" day set in product settings.
1212
* Fix - Subscription table is empty in mobile view when HPOS is enabled.
1313
* Fix - WooCommerce page header is hidden when HPOS is enabled.
14+
* Fix - Subscription updated messages missing on the Edit Subscription page when HPOS is enabled.
1415
* 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.
1516
* 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.
1617

includes/admin/class-wcs-admin-post-types.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function __construct() {
6767
add_action( 'parse_query', array( $this, 'shop_subscription_search_custom_fields' ) );
6868

6969
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
70+
add_filter( 'woocommerce_order_updated_messages', array( $this, 'post_updated_messages' ) );
7071

7172
// Add ListTable filters when CPT is enabled
7273
add_action( 'restrict_manage_posts', array( $this, 'restrict_by_product' ) );
@@ -1095,7 +1096,9 @@ public static function set_post__in_query_var( $query_vars, $post_ids ) {
10951096
* @return array
10961097
*/
10971098
public function post_updated_messages( $messages ) {
1098-
global $post, $post_ID;
1099+
global $post, $theorder;
1100+
1101+
$created_date = ! empty( $theorder ) && $theorder instanceof WC_Subscription ? $theorder->get_date_created() : $post->post_date;
10991102

11001103
$messages['shop_subscription'] = array(
11011104
0 => '', // Unused. Messages start at index 1.
@@ -1109,7 +1112,7 @@ public function post_updated_messages( $messages ) {
11091112
7 => __( 'Subscription saved.', 'woocommerce-subscriptions' ),
11101113
8 => __( 'Subscription submitted.', 'woocommerce-subscriptions' ),
11111114
// translators: php date string
1112-
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>' ),
1115+
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>' ),
11131116
10 => __( 'Subscription draft updated.', 'woocommerce-subscriptions' ),
11141117
);
11151118

0 commit comments

Comments
 (0)