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?
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.
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:
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;
break;
}
//
if($order_item->variation_id == 1950) {
$is_valid = true;
break;
}
}
if (!$is_valid)
{
throw new Exception("The order associated to your account does not contain the authorized product. Cannot continue.");
}
}
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). http://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties
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]
Thanks. Removed the entire full code though. Customers who want it can request it by Private Mail.
Sure, we’ll continue to extend the kit with additional options, however we must also keep things simple to install and configure.
Hi support, can you please download the file and share it somewhere in your website so others can download it? Some people pm me asking for the file, but I can’t promise to reply them all timely. On the other hand, sharing the code via pm makes its format funny.
The file can be downloaded at the below link: https://ufile.io/x9zk2
The link is valid only within 30 days
You may want to delete the link if needed.
Another feature that I forgot to mention: the expiry date of an activation is calculated based on the ‘completed order’ date, hence If users re-activate the software, the expired date would stay the same.
but there is one more thing to add to this logic:
if the customer renew his license (purchase) NOT in the end of his previous let say a week before the “expire date” the new license should start in the next day after the previous license, otherwise he will lose a week to his new license.