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

Commit 47bf034

Browse files
authored
Merge branch 'trunk' into add/nightly-build-workflow
2 parents 26f911e + f7dbe32 commit 47bf034

18 files changed

+293
-130
lines changed

includes/class-wcs-cart-renewal.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,20 @@ protected function set_order_awaiting_payment( $order_id ) {
257257
if ( is_a( $order_id, 'WC_Abstract_Order' ) ) {
258258
$order = $order_id;
259259
$order_id = $order->get_id();
260+
} elseif ( ! empty( $order_id ) ) {
261+
$order = wc_get_order( $order_id );
262+
}
263+
264+
// Only ever set the order awaiting payment to 0 or an Order ID - not a subscription.
265+
if ( $order && ! wcs_is_order( $order ) ) {
266+
return;
260267
}
261268

262269
WC()->session->set( 'order_awaiting_payment', $order_id );
263270
WC()->session->set( 'store_api_draft_order', $order_id );
264271

265272
if ( $order_id ) {
266-
// To avoid needing to load the order object, pass it if available, otherwise pass the order ID.
267-
$this->set_cart_hash( $order ?? $order_id );
273+
$this->set_cart_hash( $order );
268274
}
269275
}
270276

@@ -1687,7 +1693,7 @@ public function restore_order_awaiting_payment( $cart ) {
16871693
}
16881694

16891695
// If the current user has permission to pay for the order, restore the order awaiting payment session arg.
1690-
if ( $this->validate_current_user( $order ) ) {
1696+
if ( wcs_is_order( $order ) && $this->validate_current_user( $order ) ) {
16911697
$this->set_order_awaiting_payment( $order );
16921698
}
16931699

templates/emails/admin-new-renewal-order.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,52 @@
22
/**
33
* Admin new renewal order email
44
*
5-
* @author Brent Shepherd
5+
* Based on the WooCommerce core admin-new-order.php template.
6+
*
67
* @package WooCommerce_Subscriptions/Templates/Emails
7-
* @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
8+
* @version 7.3.0 - Updated for WC core email improvements.
89
*/
9-
if ( ! defined( 'ABSPATH' ) ) {
10-
exit; // Exit if accessed directly
11-
}
1210

11+
defined( 'ABSPATH' ) || exit;
12+
13+
$email_improvements_enabled = wcs_is_wc_feature_enabled( 'email_improvements' );
14+
15+
/*
16+
* @hooked WC_Emails::email_header() Output the email header
17+
*/
1318
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
1419

20+
<?php echo $email_improvements_enabled ? '<div class="email-introduction">' : ''; ?>
1521
<?php /* translators: $1: customer's billing first name and last name */ ?>
16-
<p><?php printf( esc_html_x( 'You have received a subscription renewal order from %1$s. Their order is as follows:', 'Used in admin email: new renewal order', 'woocommerce-subscriptions' ), esc_html( $order->get_formatted_billing_full_name() ) );?></p>
22+
<p><?php printf( esc_html_x( 'You have received a subscription renewal order from %1$s. Their order is as follows:', 'Used in admin email: new renewal order', 'woocommerce-subscriptions' ), esc_html( $order->get_formatted_billing_full_name() ) ); ?></p>
23+
<?php echo $email_improvements_enabled ? '</div>' : ''; ?>
1724

1825
<?php
1926
/**
2027
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
28+
* @hooked WC_Subscriptions_Email::order_download_details() Shows the order downloads table.
2129
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
2230
*/
2331
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
2432

33+
/*
34+
* @hooked WC_Emails::order_meta() Shows order meta data.
35+
*/
2536
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
2637

38+
/*
39+
* @hooked WC_Emails::customer_details() Shows customer details
40+
* @hooked WC_Emails::email_address() Shows email address
41+
*/
2742
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
2843

2944
/**
3045
* Show user-defined additional content - this is set in each email's settings.
3146
*/
3247
if ( $additional_content ) {
48+
echo $email_improvements_enabled ? '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="email-additional-content">' : '';
3349
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
50+
echo $email_improvements_enabled ? '</td></tr></table>' : '';
3451
}
3552

3653
do_action( 'woocommerce_email_footer', $email );
Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
11
<?php
22
/**
3-
* Admin new switch order email
3+
* Admin new switch order email.
4+
*
5+
* Based on the WooCommerce core admin-new-order.php template.
46
*
5-
* @author Brent Shepherd
67
* @package WooCommerce_Subscriptions/Templates/Emails
7-
* @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
8+
* @version 7.3.0 - Updated for WC core email improvements.
89
*/
9-
if ( ! defined( 'ABSPATH' ) ) {
10-
exit; // Exit if accessed directly
11-
}
1210

11+
defined( 'ABSPATH' ) || exit;
12+
13+
$email_improvements_enabled = wcs_is_wc_feature_enabled( 'email_improvements' );
14+
15+
/*
16+
* @hooked WC_Emails::email_header() Output the email header
17+
*/
1318
do_action( 'woocommerce_email_header', $email_heading, $email );
1419

1520
$switched_count = count( $subscriptions );
1621

17-
/* translators: $1: customer's first name and last name, $2: how many subscriptions customer switched */ ?>
18-
<p><?php echo esc_html( sprintf( _nx( 'Customer %1$s has switched their subscription. The details of their new subscription are as follows:', 'Customer %1$s has switched %2$d of their subscriptions. The details of their new subscriptions are as follows:', $switched_count, 'Used in switch notification admin email', 'woocommerce-subscriptions' ), $order->get_formatted_billing_full_name(), $switched_count ) );?></p>
22+
echo $email_improvements_enabled ? '<div class="email-introduction">' : '';
23+
?>
24+
<p>
25+
<?php
26+
if ( 1 === $switched_count ) {
27+
/* translators: $1: customer's first name and last name */
28+
echo esc_html( sprintf( _x( 'Customer %1$s has switched their subscription. The details of their new subscription are as follows:', 'Used in switch notification admin email', 'woocommerce-subscriptions' ), $order->get_formatted_billing_full_name() ) );
29+
} else {
30+
/* translators: $1: customer's first name and last name, $2: how many subscriptions customer switched */
31+
echo esc_html( sprintf( _x( 'Customer %1$s has switched %2$d of their subscriptions. The details of their new subscriptions are as follows:', 'Used in switch notification admin email', 'woocommerce-subscriptions' ), $order->get_formatted_billing_full_name(), $switched_count ) );
32+
}
33+
?>
34+
</p>
35+
<?php echo $email_improvements_enabled ? '</div>' : ''; ?>
1936

2037
<h2><?php esc_html_e( 'Switch Order Details', 'woocommerce-subscriptions' ); ?></h2>
2138

2239
<?php
40+
/**
41+
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
42+
* @hooked WC_Subscriptions_Email::order_download_details() Shows the order downloads table.
43+
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
44+
*/
2345
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
2446

47+
/*
48+
* @hooked WC_Emails::order_meta() Shows order meta data.
49+
*/
2550
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
2651
?>
2752

@@ -32,13 +57,19 @@
3257
do_action( 'woocommerce_subscriptions_email_order_details', $subscription, $sent_to_admin, $plain_text, $email );
3358
}
3459

60+
/*
61+
* @hooked WC_Emails::customer_details() Shows customer details
62+
* @hooked WC_Emails::email_address() Shows email address
63+
*/
3564
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
3665

3766
/**
3867
* Show user-defined additional content - this is set in each email's settings.
3968
*/
4069
if ( $additional_content ) {
70+
echo $email_improvements_enabled ? '<div class="email-additional-content">' : '';
4171
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
72+
echo $email_improvements_enabled ? '</div>' : '';
4273
}
4374

4475
do_action( 'woocommerce_email_footer', $email );

templates/emails/admin-payment-retry.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55
* Email sent to admins when an attempt to automatically process a subscription renewal payment has failed
66
* and a retry rule has been applied to retry the payment in the future.
77
*
8-
* @author Prospress
98
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
10-
* @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
9+
* @version 7.3.0 - Updated for WC core email improvements.
1110
*/
1211

13-
if ( ! defined( 'ABSPATH' ) ) {
14-
exit;
15-
}
12+
defined( 'ABSPATH' ) || exit;
13+
14+
$email_improvements_enabled = wcs_is_wc_feature_enabled( 'email_improvements' );
1615

1716
/**
1817
* @hooked WC_Emails::email_header() Output the email header
1918
*/
2019
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
2120

21+
<?php echo $email_improvements_enabled ? '<div class="email-introduction">' : ''; ?>
2222
<?php /* translators: %1$s: an order number, %2$s: the customer's full name, %3$s: lowercase human time diff in the form returned by wcs_get_human_time_diff(), e.g. 'in 12 hours' */ ?>
23-
<p><?php echo esc_html( sprintf( _x( 'The automatic recurring payment for order #%d from %s has failed. The payment will be retried %3$s.', 'In customer renewal invoice email', 'woocommerce-subscriptions' ), $order->get_order_number(), $order->get_formatted_billing_full_name(), wcs_get_human_time_diff( $retry->get_time() ) ) ); ?></p>
23+
<p><?php echo esc_html( sprintf( _x( 'The automatic recurring payment for order #%1$d from %2$s has failed. The payment will be retried %3$s.', 'In customer renewal invoice email', 'woocommerce-subscriptions' ), $order->get_order_number(), $order->get_formatted_billing_full_name(), wcs_get_human_time_diff( $retry->get_time() ) ) ); ?></p>
2424
<p><?php esc_html_e( 'The renewal order is as follows:', 'woocommerce-subscriptions' ); ?></p>
25+
<?php echo $email_improvements_enabled ? '</div>' : ''; ?>
2526

2627
<?php
2728

@@ -46,7 +47,9 @@
4647
* Show user-defined additional content - this is set in each email's settings.
4748
*/
4849
if ( $additional_content ) {
50+
echo $email_improvements_enabled ? '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="email-additional-content">' : '';
4951
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
52+
echo $email_improvements_enabled ? '</td></tr></table>' : '';
5053
}
5154

5255
/**

templates/emails/cancelled-subscription.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Cancelled Subscription email
44
*
55
* @package WooCommerce_Subscriptions/Templates/Emails
6-
* @version 7.3.0 Provide additional context about the subscription status (if it is pending cancellation, or fully cancelled).
6+
* @version 7.3.0 - Updated for WC core email improvements.
77
*/
8-
if ( ! defined( 'ABSPATH' ) ) {
9-
exit; // Exit if accessed directly
10-
}
8+
9+
defined( 'ABSPATH' ) || exit;
10+
11+
$email_improvements_enabled = wcs_is_wc_feature_enabled( 'email_improvements' );
1112

1213
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
1314

15+
<?php echo $email_improvements_enabled ? '<div class="email-introduction">' : ''; ?>
1416
<p>
1517
<?php
1618
if ( 'pending-cancel' === $subscription->get_status() ) {
@@ -29,6 +31,7 @@
2931
}
3032
?>
3133
</p>
34+
<?php echo $email_improvements_enabled ? '</div>' : ''; ?>
3235

3336
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
3437
<thead>
@@ -74,7 +77,9 @@
7477
* Show user-defined additional content - this is set in each email's settings.
7578
*/
7679
if ( $additional_content ) {
80+
echo $email_improvements_enabled ? '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="email-additional-content">' : '';
7781
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
82+
echo $email_improvements_enabled ? '</td></tr></table>' : '';
7883
}
7984

8085
do_action( 'woocommerce_email_footer', $email );

templates/emails/customer-completed-renewal-order.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,53 @@
22
/**
33
* Customer completed renewal order email
44
*
5-
* @author Brent Shepherd
5+
* Based on the WooCommerce core customer-completed-order.php template.
6+
*
67
* @package WooCommerce_Subscriptions/Templates/Emails
7-
* @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
8+
* @version 7.3.0 - Updated for WC core email improvements.
89
*/
910

10-
if ( ! defined( 'ABSPATH' ) ) {
11-
exit; // Exit if accessed directly
12-
}
11+
defined( 'ABSPATH' ) || exit;
1312

13+
$email_improvements_enabled = wcs_is_wc_feature_enabled( 'email_improvements' );
14+
15+
/*
16+
* @hooked WC_Emails::email_header() Output the email header
17+
*/
1418
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
1519

20+
<?php echo $email_improvements_enabled ? '<div class="email-introduction">' : ''; ?>
1621
<?php /* translators: %s: Customer first name */ ?>
1722
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce-subscriptions' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
1823
<p><?php esc_html_e( 'We have finished processing your subscription renewal order.', 'woocommerce-subscriptions' ); ?></p>
24+
<?php echo $email_improvements_enabled ? '</div>' : ''; ?>
1925

2026
<?php
27+
/**
28+
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
29+
* @hooked WC_Subscriptions_Email::order_download_details() Shows the order downloads table.
30+
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
31+
*/
2132
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
2233

34+
/*
35+
* @hooked WC_Emails::order_meta() Shows order meta data.
36+
*/
2337
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
2438

39+
/*
40+
* @hooked WC_Emails::customer_details() Shows customer details
41+
* @hooked WC_Emails::email_address() Shows email address
42+
*/
2543
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
2644

2745
/**
2846
* Show user-defined additional content - this is set in each email's settings.
2947
*/
3048
if ( $additional_content ) {
49+
echo $email_improvements_enabled ? '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="email-additional-content">' : '';
3150
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
51+
echo $email_improvements_enabled ? '</td></tr></table>' : '';
3252
}
3353

3454
do_action( 'woocommerce_email_footer', $email );

templates/emails/customer-completed-switch-order.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,37 @@
22
/**
33
* Customer completed subscription change email
44
*
5-
* @author Brent Shepherd
5+
* Based on the WooCommerce core customer-completed-order.php template.
6+
*
67
* @package WooCommerce_Subscriptions/Templates/Emails
7-
* @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
8+
* @version 7.3.0 - Updated for WC core email improvements.
89
*/
910

10-
if ( ! defined( 'ABSPATH' ) ) {
11-
exit; // Exit if accessed directly
12-
}
11+
defined( 'ABSPATH' ) || exit;
12+
13+
$email_improvements_enabled = wcs_is_wc_feature_enabled( 'email_improvements' );
1314

15+
/*
16+
* @hooked WC_Emails::email_header() Output the email header
17+
*/
1418
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
1519

20+
<?php echo $email_improvements_enabled ? '<div class="email-introduction">' : ''; ?>
1621
<?php /* translators: %s: Customer first name */ ?>
1722
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce-subscriptions' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
1823
<p><?php esc_html_e( 'You have successfully changed your subscription items. Your new order and subscription details are shown below for your reference:', 'woocommerce-subscriptions' ); ?></p>
19-
24+
<?php echo $email_improvements_enabled ? '</div>' : ''; ?>
2025
<?php
26+
/**
27+
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
28+
* @hooked WC_Subscriptions_Email::order_download_details() Shows the order downloads table.
29+
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
30+
*/
2131
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
2232

33+
/**
34+
* @hooked WC_Emails::order_meta() Shows order meta data.
35+
*/
2336
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
2437
?>
2538

@@ -30,13 +43,19 @@
3043
do_action( 'woocommerce_subscriptions_email_order_details', $subscription, $sent_to_admin, $plain_text, $email );
3144
}
3245

46+
/**
47+
* @hooked WC_Emails::customer_details() Shows customer details
48+
* @hooked WC_Emails::email_address() Shows email address
49+
*/
3350
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
3451

3552
/**
3653
* Show user-defined additional content - this is set in each email's settings.
3754
*/
3855
if ( $additional_content ) {
56+
echo $email_improvements_enabled ? '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="email-additional-content">' : '';
3957
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
58+
echo $email_improvements_enabled ? '</td></tr></table>' : '';
4059
}
4160

4261
do_action( 'woocommerce_email_footer', $email );

0 commit comments

Comments
 (0)