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 1 reply, has 2 voices.

Last updated by Yvette 1 month ago.

Assigned support staff: Yvette.

Author Posts
September 15, 2019 at 3:24 pm

karinaR

I am trying to get all the products on sale.
Recently my main language was English, but now it is Russian.
I put the sale price in the original product in English, at the Rus product there are lock icons near the fields and price there is visible.

$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
'post_status' => 'publish',
'suppress_filters' => 0,
'post__in' => array_merge( array( 0 ), wc_get_product_ids_on_sale() )
);
$featured_products = new WP_Query( $args );

Link to a page where the issue can be seen:
hidden link at section СКИДКИ at the bottom of page.

I expected to see:
one translated product

Instead, I got:
nothing.

If I will change "suppress_filters" to "0", I will see an English product.

September 16, 2019 at 5:37 pm #4582987

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hello

I took a look at your code and I believe the issue is that you are using a woocommerce call wc_get_product_ids_on_sale() which is not "aware" /"filtered" on current/active session language and is therefore using the default system language (EN).

What you can try, is to get the translated language objects from the returned array using the WPML API. Specifically, once you have the products on sale,
- determine the active language
https://wpml.org/wpml-hook/wpml_current_language/
- then, retrieve the translated object ids
https://wpml.org/wpml-hook/wpml_object_id/

You would use this translated array of object-ids to display on your frontend.

I wait for your comments

The topic ‘[Closed] Woo sale products are visible only at one language’ is closed to new replies.