This thread is resolved. Here is a description of the problem and solution.
Problem:
Woocommerce dynamic pricing rules for categories not applying to the second language.
Solution:
Permanent fix will be included in a future release of WCML.
The workaround used in this case:
- Open the "wp-content/plugins/woocommerce-dynamic-pricing/admin/classes/category_pricing_rules_admin.class.php" file then replace the following snippet (lines 425 - 430):
<?php foreach($terms as $term): ?> <?php $term_checked = (isset( $collector['args']['cats'] ) && is_array( $collector['args']['cats'] ) && in_array( $term->term_id, $collector['args']['cats'] )) ? true : false; ?> <option <?php selected($term_checked); ?> value="<?php esc_attr_e($term->term_id); ?>"><?php esc_html_e($term->name); ?></option> <?php endforeach; ?>
- With this
<?php foreach($terms as $term): ?> <?php $term_checked = (isset( $collector['args']['cats'] ) && is_array( $collector['args']['cats'] ) && in_array( $term->term_id, $collector['args']['cats'] )) ? true : false; ?> <option <?php selected($term_checked); ?> value="<?php esc_attr_e($term->term_id); ?>"><?php esc_html_e($term->name); ?></option> <?php //wpml workaround $wpml_languages = apply_filters( 'wpml_active_languages', NULL ); if (is_array ($wpml_languages)) { foreach ($wpml_languages as $wpml_language) { $translated_id = apply_filters( 'wpml_object_id', $term->term_id, 'product_cat', TRUE, $wpml_language['language_code'] ); $translated_name = get_term( $translated_id , 'product_cat' ); if ($translated_id != $term->term_id) { ?> <option <?php selected($term_checked); ?> value="<?php esc_attr_e($translated_id); ?>"><?php echo '('.$wpml_language['language_code'].') '; esc_html_e($translated_name->name); ?></option> <?php } ?> <?php } ?> <?php } ?> <?php endforeach; ?>
- Also add the same workaround on the "create_target_selector" function (lines 445-448):
<?php foreach($terms as $term): ?> <?php $term_checked = (isset( $targets ) && is_array( $targets ) && in_array( $term->term_id, $targets )) ? true : false; ?> <option <?php selected($term_checked); ?> value="<?php esc_attr_e($term->term_id); ?>"><?php esc_html_e($term->name); ?></option> <?php //WPML workaround $wpml_languages = apply_filters( 'wpml_active_languages', NULL ); if (is_array ($wpml_languages)) { foreach ($wpml_languages as $wpml_language) { $translated_id = apply_filters( 'wpml_object_id', $term->term_id, 'product_cat', TRUE, $wpml_language['language_code'] ); $translated_name = get_term( $translated_id , 'product_cat' ); if ($translated_id != $term->term_id) { ?> <option <?php selected($term_checked); ?> value="<?php esc_attr_e($translated_id); ?>"><?php echo '('.$wpml_language['language_code'].') '; esc_html_e($translated_name->name); ?></option> <?php } ?> <?php } ?> <?php } ?> <?php endforeach; ?>
- Go to "WooCommerce -> Dynamic Pricing - -> Tab Category -> Advanced Category Pricing" check both language categories are added and showing.
- Save
Relevant Documentation:
https://wpml.org/it/forums/topic/problemi-con-woo-dynamic-pricing/
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 10 replies, has 3 voices.
Last updated by The Smalls 9 months, 1 week ago.
Assigned support staff: Dražen Duvnjak.