Skip Navigation

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 8 replies, has 3 voices.

Last updated by Raja Mohammed 3 weeks, 2 days ago.

Assigned support staff: Raja Mohammed.

Author Posts
January 16, 2021 at 1:05 pm #7858965

erolM

I am trying to: Update variation price via REST which needs to sync to other translations

Link to a page where the issue can be seen: /

I expected to see: Synced prices.

Instead, I got: Prices are not synced. Problem is in class WCML_Synchronize_Product_Data where save_post is not ran when we perform a REST call. So actual code should be

if ( is_admin() || wpml_is_rest_request() ) {
  // filters to sync variable products.
  add_action( 'save_post', [ $this, 'synchronize_products' ], PHP_INT_MAX, 2 ); // After WPML.
  ...
January 16, 2021 at 4:02 pm #7859497

Laura
Supporter

Languages: English (English ) Italian (Italiano ) Portuguese (Brazil) (Português )

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

Hi,

thanks for contacting us.

Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

Did you update to WCML 4.11.0? This version includes a better integration with Rest API

January 16, 2021 at 7:29 pm #7860011

erolM

Hello

Where do I get 4.11.0 version? I can only access 4.10.4 on https://wordpress.org/plugins/woocommerce-multilingual/ ?

But if I check your latest code on hidden link the issue is still there.

Please assign this ticket to your colleagues. It's a super quick fix that solves quite a huge but in the plugin.

January 17, 2021 at 8:39 pm #7864145

erolM

Hello

Actually the code fix that I posted does NOT fix the issue. Actual fix is to

1. WCML_Synchronize_Variations_Data->add_hooks() to be called also if wpml_is_rest_request()
2. add_action for woocommerce_rest_insert_product_variation_object and inside call sync_product_variations_action with parent_id

add_action('woocommerce_rest_insert_product_variation_object', [$this, 'sync_product_variations_rest_action']);

...

public function sync_product_variations_rest_action($product) {
    $this->sync_product_variations_action( $product->get_parent_id() );
}

The issue is that you do not attach to any action when variation price has updated.

January 20, 2021 at 6:11 am #7883755

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello there,

The latest WCML version 4.11 is release for our client and should be available for download from your site dashboard Plugins > Add New > Commercial, However i see that you are subscribed to Multilingual blog license which does not allow woo commerce translation also the WCML plugin will not function properly without WPML sting translation.

WCML 4.11 is specially focused on Rest API support, I have created a test site for you with latest WPML and WCML plugin, Please try to reproduce the issue, If the issue still persists let me know the steps that you have performed

hidden link

Please be noted in any case WooCommerce Multilingual requires WPML Multilingual CMS license that has access to String translations

January 20, 2021 at 7:43 am #7884059

erolM

Hello

Thank you for your reply. The issue is still present. I have created a test product (with variations) that syncs to FR language. If you update price in admin, it will be synced to FR, but if you update it with REST API, it does NOT update price in FR version.

ck: ck_2bc6f876fb2ee5c42186220f19bd353fd565fa97
cs: cs_45e10cc412ab3e566862ad9d6f78319ec3088f88

PUT hidden link

{
	"regular_price": "110"
}

I executed the PUT update to update price, but price is not synced to FR version. If you add the code in previous post, it works.

January 25, 2021 at 6:12 pm #7925083

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue is reported to our second tier. Further action will be taken by our developers based on the further proceedings.

Thanks for reporting the issue.

February 1, 2021 at 10:22 am #7975187

erolM

I'm still waiting for a fix, but I keep getting an email that this thread will be closed.

February 1, 2021 at 11:59 am #7976387

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue is reported to our developers, A fix will be eventually added in any of the upcoming WooCommerce Multilingual release. I would like to also highlight even though the fix will be available this can only work with WPML Multilingual CMS along with Woo Commerce Multilingual and string translation plugin and not just with the WPML Multilingual Blog license.