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.
|October 7, 2019 at 8:22 am #4705305|
Tell us what you are trying to do?
I am trying to programatically creating a WooCommerce product + create a translation of this product.
Is there any documentation that you are following?
Is there a similar example that we can see?
$default_language = 'da';
$original_post_id = apply_filters( 'wpml_object_id', $original_post_id, 'product', false, $default_language);
$wpml_element_type = apply_filters('wpml_element_type', 'product');
$set_language_args = array(
do_action( 'wpml_set_element_language_details', $set_language_args );
|October 8, 2019 at 11:40 am #4714787|
Languages: English (English )
Timezone: Europe/Sofia (GMT+03:00)
Hello and thank you for contacting us.
The SKU usually has to be unique, and that is why we have custom logic that syncs that for the translations.
Another way probably is to use our REST api as noted here: https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/
And another way is probably to duplicate to the translation using our hooks as noted here: https://wpml.org/wpml-hook/wpml_admin_make_post_duplicates/
|October 8, 2019 at 11:42 am #4714791|
My issue is resolved now. Thank you!
I ended up adding
add_filter( 'wc_product_has_unique_sku', '__return_false' );
Before importing, and that fixed the issue