I am using woocommerce plugin for ecommerce site. Problem is that it allows maximum 50 variations for a product, but my client requires around 350 variations with attributes size, color etc. etc. Is there a way to tweak the code or anything else?
Thanks,
Frank
Just to clarify, there is no limit to 50 variations for one product in Woocommerce – this is a big misunderstanding.
You certainly can have way more variations than that. I have done it myself numerous times and never had a problem. For a overview concerning variations take a look at the woocommerce documentation: Product Variations.
As far as the limit goes, this concerns the possibility to automatically link variations: Linking possible variations. There it says:
The important part is »max 50 per run« – what this means is, that you have to run it several times if your selection of attributes leads to more possible variations. The limit is there to »to prevent memory issues« – additionally see @brasofilo’s answer.
Additional information: @brasofilo’s answer refers to a rather old version, keep that in mind; @shamim539’s refers to the newer 2.x version, but can be improved.
The code sample he gave is inside a conditional, that checks if the variable has been defined – take a look:
So there is no need to do the change inside the
woocommerce-ajax.php
file, this will be overridden on plugin updates anyway. Just define the variable inside yourfunctions.php
:But: If you are going to increase the limit be sure your server can handle the increased limit.
If you have problems saving large amounts of data – like @user1418998 suggested – this is documented as well: Problems with large amounts of data not saving (variations, rates etc).
From the Woo forums:
That said, looks like you have to hack the plugin code or create an action hook (not sure how to, but it is supported by the plugin in this function case) to modify the behavior of the function
woocommerce_link_all_variations
.Max 100 is an original comment in the file.
On the following location:
Find the PHP file:
woocommerce-ajax.php
.On line number 603, do:
* Set your max value, I set it 149
Basing on my expirience, problem can be hidden in php.ini file! Search for max_input_vars uncomment it and increase up to 2000 or greater basing on your needs. In my case without this modification i could input at most 40 variations, if more was order mixing , images and prices wasn’t saving. I had so huge variable inputs because of Woocommerce WPML plugin and other plugins like Ether Content Builder working together. Correct my English if needed.