Hello,
To fix this issue (which happened after a data format change in the previous update), please add the following code snippet to the functions.php file in the child theme. Then go to any page on your website to regenerate the data format. It should solve the problem, so you can delete the code from the file after that.
if ( ! function_exists( 'woodmart_update_dynamic_discounts_data' ) ) {
/**
* Update dynamic discounts data.
*/
function woodmart_update_dynamic_discounts_data() {
if ( ! woodmart_get_opt( 'discounts_enabled' ) ) {
return;
}
$discounts_ids = get_posts(
array(
'post_type' => 'wd_woo_discounts',
'posts_per_page' => -1,
'fields' => 'ids',
'post_status' => 'any',
)
);
if ( ! is_array( $discounts_ids ) || empty( $discounts_ids ) ) {
return;
}
foreach ( $discounts_ids as $discount_id ) {
$discount_rules = get_post_meta( $discount_id, 'discount_rules', true );
$discount_condition = get_post_meta( $discount_id, 'discount_condition', true );
if ( ! empty( $discount_rules ) && is_serialized( $discount_rules ) ) {
$unserialized_rules = maybe_unserialize( $discount_rules );
if ( is_array( $unserialized_rules ) && ! empty( $unserialized_rules ) ) {
update_post_meta( $discount_id, 'discount_rules', $unserialized_rules );
}
}
if ( ! empty( $discount_condition ) && is_serialized( $discount_condition ) ) {
$unserialized_condition = maybe_unserialize( $discount_condition );
if ( is_array( $unserialized_condition ) && ! empty( $unserialized_condition ) ) {
update_post_meta( $discount_id, 'discount_condition', $unserialized_condition );
}
}
delete_transient( 'wd_transient_discounts_rule_' . $discount_id );
}
delete_transient( 'wd_all_discounts_post_ids' );
}
add_action( 'init', 'woodmart_update_dynamic_discounts_data' );
}
Kind Regards