Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
Uploading products without uploading to main/default language via REST API.

Solution:
See https://wpml.org/forums/topic/uploading-products-without-uploading-to-main-default-language/#post-14722793 for details.

Relevant Documentation:

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

Last updated by Waqas Bin Hasan 1 year, 4 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
November 1, 2023 at 12:58 pm #14707519

jensE-7

Tell us what you are trying to do?
I have products that i want uploaded only to a secondary language and not in my main/default language, since some products can be sold in one country, but not in others.

Uploading the products through WooCommerce REST API doesn't work if the product isn't uploaded to the main/default language first. But i can do it manually through WP-Admin dashboard by adding the product manually in the secondary-language site.

Is there any documentation that you are following?
No

What is the link to your site?
e-bloss.se for main language. (e-sug.dk for domain to secondary-language).

November 2, 2023 at 7:25 am #14712881

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

Apparently you can use WP All Import (or any other import/export compatible) plugin to bulk upload content to a specific language. Please see https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/ for details.

However, I'll advise to fix the following beforehand:

IMPORTANT: Take full backup of your website and database beforehand. It is highly advised to try the following on a staging/dev site first, so your live website isn't compromised.

1) Fix “WP Memory Limit” to at least 128MB while 256MB is recommended. See https://wpml.org/home/minimum-requirements/ for detailed information. You can set this in your wp-config.php file by adding following code:

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Remember to add these lines before the line where it says:
/* That's all, stop editing! Happy publishing. */

2) Update WPML plugins to the latest versions.

Regards.

November 2, 2023 at 1:17 pm #14717047

jensE-7

WPML All import plugin will not solve our problem.

We are uploading products to the shop through WooCommerce REST API, and want to be able to upload a product on a secondary langauge, without uploading/showing the product when the user is toggled to the primary language.

This is already possible through manually uploading the product through the WP-Admin dashboard, but if uploading through the REST API, uploading first to the primary/default language is needed, before being able to upload to the secondary ones.

Is there a way we can upload/show an item on a secondary language site, without showing or having to upload on the primary/default language?

November 3, 2023 at 7:04 am #14722793

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates.

I understand your point and did some more research. Looks like WooCommerce REST API alone won't be able to achieve this because there's no multilingual attribute available for product attributes (hidden link).

While, in your case you want to create product in secondary language, while keeping it "unlinked" to another product in primary language (i.e. a translation) - thus considering it a standalone product in secondary language.

So as per my understanding, you can achieve this by using WordPress REST API with WooCommerce Multilingual, please see https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/#create-products for details.

In the example in the said guide, I think you can specify the desired language, as well as, "translation_of" parameter to empty (i.e. null or ''). I haven't tried this but I think that may help you achieving your goal.

Additionally, I'll also suggest to check WCML Hooks reference at https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/, in case if it may also be helpful in your custom coding needs.

I hope that helps.

November 6, 2023 at 10:29 am #14736609

jensE-7

Thank you for the fast and splendid support 🙂 my issue is resolved.