Woocommerce kit and variations


The new check of order contains the allowed product works very good but NOT support variations in the product.

If you can add this validation to the next update it will be amazing, because right now I have a variation product and you can activate the more expensive variation with the less expensive variation order.

Thank you.


Hi see my question

…their update makes no sense for variation products…If you have 30 Variation products you will have 30 different ids and you need to install the kit 30 times…dont make any sense and a feature they must rectify as I am not going to install kit 30 times


All variation in one kit folder it’s a very very nice feature to have, but it is NOT “must feature” but to check variations that someone not activate a more expensive variation with the less expensive variation order - that’s MUST TO HAVE.


Having one kit for all products would result in more complex installation instructions because you would have to modify several PHP files.


Sure, we have to think about that. Probably another additional check to add.


So can we summarize: each product and each product variation needs one toolkit?


If you sell different workbooks with the same WooCommerce, yes.


I’m a little confused. Assuming I want to distribute three license versions like license 1 with 1 month, a license with 12 months and an unlimited license, this would be possible because a variable product has a unique ID, right?

So i would install different activation kits with that unique id, so every license version got its own license kit. Does that work?

Or what is the exact problem with that?


Yes, and you create a different “activation” subfolder in your WordPress website for each variation.


Yes. Several WooCommerce Integration Kits can be installed on the same woocommerce website. However, in your case, you would have to modify the PHP source code to change the expiration date for the activation key, based on which product ID was purchased.


BlockquoteHowever, in your case, you would have to modify the PHP source code to change the expiration date for the activation key, based on which product ID was purchased.

You mean customizing the maincontroller.php?


Yes, in this function:

The controller could be customized so that depending on the product_id available in the order, a different expiration setting is configured.


Hi, i followed the instructions. Now, i have variable products according to different licence models.
Nevertheless, i get the following message. At the moment, there is just one product created for testing
May you please give me advise what this means, please?


When i have the product created as a simple product it works fine. May i let the "wpcheckproductid = " field empty? The product id is 1860 (for e.g.) and the id of the variable is #1950. Can i add #1950?


The problem is due to the incorrect product ID in the order.
If you want to check for variations, you should modify the PHP code in the controller:

// Check if the order contains the product that is allowed (the product id is defined in config.ini)

$allowed_prod_id = $f3->get(‘wpcheckproductid’);

if (!empty($allowed_prod_id))

  $is_valid = false;
  	// Scan all ordered items in the order
  	$order_items = $order_data->line_items;
  foreach ( $order_items as $order_item )
  		if ($order_item->product_id == $allowed_prod_id)

Then, in that loop, you must also check for possible allowed variations:

if ($order_item->variation_id == 1950)


Sorry for jumping the discussion, but I have a similar issue.
Say the variation_ID is 1950 corresponding to a licence length of 30 days which is an attribute of that variation product. How can I extract that attribute with that variation_ID?
A series of attributes would be something like 30 days|60 days|90 days|365 days|999999 days|

$allowed_prod_id = $f3->get('wpcheckproductid');
					if (!empty($allowed_prod_id))
						$is_valid = false;
						// Scan all ordered items in the order
						$order_items = $order_data->line_items;
							foreach ( $order_items as $order_item )
								if ($order_item->product_id == $allowed_prod_id)
									$is_valid = true;
								if($order_item->variation_id == 1950) {
									$is_valid = true;
						if (!$is_valid)
							throw new Exception("The order associated to your account does not contain the authorized product. Cannot continue.");


That way?


Yes, but remove the first break otherwise the second “if” will be ignored.


It would be better to change the maincontroller.php’s code depending on the variation ID to create a key with a different expiration date. As you can see gere, WooCommerce doesn’t give us a lot of information about purchased products (product id, variation id and no custom entries).


It works with both variants


Thanks for your reply. I’ve modified the MainController.php, so now it is able to allow multiple variations of ONE product with only ONE kit installation. It also can expire the licences based on purchased licence lengths. I marked the location where I made changes to the php file - search for the “xxx” text. It works for me, and you may want to implement it some ways to the standard kit to benefit everyone in this community If you think it is useful. See the full code below:
[edit removed]