1

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

4 Answers 4

4

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:

Instead of adding each variation one at a time, you can click the ‘link all variations’ button. This will create a new variation for each and every possible combination of variation attributes (max 50 per run).

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:

if ( ! defined( 'WC_MAX_LINKED_VARIATIONS' ) ) {
    define( 'WC_MAX_LINKED_VARIATIONS', 49 );
}

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 your functions.php:

    define( 'WC_MAX_LINKED_VARIATIONS', 249 );

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).

2

From the Woo forums:

We have a limit of 50 linked variations per product right now (to prevent memory issues), anything above that is considered to be very complex and in need of some custom work. It is not easy to manage a single product with over 3000 variations, in no eCommerce software out there.

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.

/*
 * File: /plugins/woocommerce/woocommerce-ajax.php
 * Line: 487
 * WooCommerce: v1.5.6
 */
// Max 100
if ($added>49) break;
2
  • Thanks,Brasofilo,..but I was wondering how did the guy with this post did having huge nos. of variations?? wordpress.stackexchange.com/questions/53750/…
    – Frank
    Jun 6, 2012 at 15:32
  • Well, try to put 350 where I'm signaling... But it would be better if you tested this in a clone site if yours is already live.
    – brasofilo
    Jun 6, 2012 at 18:23
0

On the following location:

plugins/woocommerce/woocommerce-ajax.php

Find the PHP file: woocommerce-ajax.php.

On line number 603, do:

define( 'WC_MAX_LINKED_VARIATIONS', 149 );

* Set your max value, I set it 149

0

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.

1
  • 1
    it's max_input_vars, not max_var_inputs
    – Milo
    Sep 11, 2013 at 15:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.