Skip Navigation

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 7 months, 1 week ago.

Assigned support staff: Dražen Duvnjak.

Author Posts
April 8, 2020 at 3:44 pm #5867487

The Smalls

Hi, after seeing https://wpml.org/plugin/woocommerce-dynamic-pricing/
i decided to buy the plugin.
The rules are not applying to the secondary language.
As you can see in the images, i've set a discount : buy 2 from category A, get 1 free from the same category.
In main lang (el) the discount is applied, but in the secondary i get nothing.

After contacting the developers, they replied :
I don’t have the ability to make WPML translate things properly inside of Dynamic Pricing. We do nothing non-standard with the extension, and we don’t want to add in non-standard things just to try to support one plugin which is buggy at best when it comes to these types of things. WPML should be able to assist with whatever particular issue you are encountering. I believe they have snippets and solutions already in place to assist.
Sorry for the trouble and if you have any other questions please let me know.

can you please release a fix, as users add stuff to their carts and cant use the discounts?

regards,

April 10, 2020 at 6:44 am #5881351

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I can see we have some open issues with WooCommerce Dynamic Pricing, on which our developers are currently working on.

Please allow me some time to check with the developers on these
plugin issues and if we have some quick fix to provide.

I will get back to you soon.

Thanks for understanding.
Drazen

April 10, 2020 at 11:36 am #5883633

The Smalls

Hi, i'm waiting for a temporary fix, as it's very serious issue.
best regards,

April 10, 2020 at 2:56 pm #5884611

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I have been able to replicate the issue on a clean minimal install and confirm there is a potential compatibility issue. I have forward all information about a potential bug to our developers for testing and confirmation.

I am currently waiting for an answer and confirmation from them. After they have confirmed bug this ticket will be escalated to our Compatibility team to work on a fix.

I will update you first thing I receive new pieces of information. Also as soon as I have some workaround to share, I will contact you.

Sorry for the trouble caused, I understand this is causing you serious issues. Be sure we are working the best we can to solve this issue.

Thanks for understanding and patience.

Drazen

April 14, 2020 at 6:22 am #5901117

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I just wanted to let you know that I've escalated this ticket to our Compatibility team.

They are taking a look at the issue and I will update as soon as I have some new info.

Please note that this process may take a while.

Thank you for your patience.

Regards,
Drazen

April 15, 2020 at 7:16 am #5910517

Jerzy Afanasjew

-deleted-

April 17, 2020 at 12:29 pm #5932821

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I bring good news, our developers have found a problem.

We are working on a permanent fix in WCML, but in the meantime, developers provided a workaround you can use. I tested it and it works as expected.

Please replace this file wp-content/plugins/woocommerce-dynamic-pricing/admin/classes/category_pricing_rules_admin.class.php with the attached file.

File: hidden link

I will update you as soon as I have new information on a WCML fix.

Thanks for understanding and patience.

Drazen

April 17, 2020 at 2:57 pm #5934125

The Smalls

That fix doesnt work in my setup.
I restored the original file.
Woocommerce multilingual, in the last year (at least) has too many bugs that break very important parts of out sites.
This of the current ticket for example, that a user can very easily sue a company for false advertising.
And this for example that stopped users from ordering : https://wpml.org/forums/topic/no-products-matched-your-selection-please-choose-a-different-combination-error/
And many other.
You should reconsider your work (not you personally), as previous errors and errors to come lead us to other multilanguage solutions. And that is not only my opinion, it;s also the opinion of many developers discussing in woocommerce forums for a long time now.
10 days for a critical error is too much.

April 18, 2020 at 6:36 am #5937497

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Thanks for the feedback.

Hmm, strange, it should work. We tested on a few different websites.

Can you please try again while following the next steps:

- change the file as described
- Go to Dynamic pricing rules check both language categories are added and showing. In my case, these are Test (English) and Test ES (Spanish). Please check the attached screenshot.
- Clear all cache
- visit webpage in incognito mode

Let me know how it goes.

I am sorry for any troubles our plugins have caused you, but be sure we are giving our best. Sometimes these bugs don't solely come from our plugins. I hope you understand our side. 🙂

I will be waiting for your feedback.

Thanks and regards.
Drazen

April 18, 2020 at 10:25 am #5938263

The Smalls

Hi, you didnt mentioned before that i should set the categories in both languages in the plugin settings.
Now it's working.

April 18, 2020 at 10:25 am #5938265

The Smalls

My issue is resolved now. Thank you!