Skip to content

Commit b9c136a

Browse files
committed
Prevent conflicts between parent and variation price strings.
1 parent 9e1d2da commit b9c136a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

woocommerce-subscriptions-custom-pricestring.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Author: Prospress Inc.
77
* Author URI: https://prospress.com/
88
* License: GPLv3
9-
* Version: 1.0.4
9+
* Version: 1.0.5
1010
* WC requires at least: 3.0.0
1111
* WC tested up to: 3.4.0
1212
*
@@ -211,12 +211,14 @@ function strip_tags_of_custom_price_value( $price_string_value ) {
211211
function save_custom_price_string( $post_id ) {
212212
if ( isset( $_REQUEST['_custom_price_string'] ) ) {
213213

214-
// If it is coming from a variable subscription product, skip it (as we already use the woocommerce_save_product_variation hook for this purpose).
215-
if ( is_array( $_REQUEST['_custom_price_string'] ) ) {
216-
return;
214+
$custom_price_string = $_REQUEST['_custom_price_string'];
215+
216+
// If it is coming from a variable subscription product, get only the first element (the one that belongs to the parent product) as we're already saving the variation ones in a different function.
217+
if ( is_array( $custom_price_string ) ) {
218+
$custom_price_string = $custom_price_string[0];
217219
}
218220

219-
$custom_price_string = wp_unslash( $_REQUEST['_custom_price_string'] );
221+
$custom_price_string = wp_unslash( $custom_price_string );
220222
update_post_meta( $post_id, '_custom_price_string', $custom_price_string );
221223

222224
}

0 commit comments

Comments
 (0)