Skip to content

Commit

Permalink
Prevent conflicts between parent and variation price strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bernattorras committed Dec 17, 2021
1 parent 9e1d2da commit b9c136a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions woocommerce-subscriptions-custom-pricestring.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: Prospress Inc.
* Author URI: https://prospress.com/
* License: GPLv3
* Version: 1.0.4
* Version: 1.0.5
* WC requires at least: 3.0.0
* WC tested up to: 3.4.0
*
Expand Down Expand Up @@ -211,12 +211,14 @@ function strip_tags_of_custom_price_value( $price_string_value ) {
function save_custom_price_string( $post_id ) {
if ( isset( $_REQUEST['_custom_price_string'] ) ) {

// If it is coming from a variable subscription product, skip it (as we already use the woocommerce_save_product_variation hook for this purpose).
if ( is_array( $_REQUEST['_custom_price_string'] ) ) {
return;
$custom_price_string = $_REQUEST['_custom_price_string'];

// 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.
if ( is_array( $custom_price_string ) ) {
$custom_price_string = $custom_price_string[0];
}

$custom_price_string = wp_unslash( $_REQUEST['_custom_price_string'] );
$custom_price_string = wp_unslash( $custom_price_string );
update_post_meta( $post_id, '_custom_price_string', $custom_price_string );

}
Expand Down

0 comments on commit b9c136a

Please sign in to comment.