• Resolved mennovink

    (@mennovink)


    When i sell a license through the shop then the expiresAt field is being populated and i can use that to see if a license is still valid.
    Is it possible to do something similar with manually generated licenses? ie when generating a new key in the delivered state it automatically uses the validFor field to populate the expiresAt?

Viewing 7 replies - 1 through 7 (of 7 total)
  • @mennovink by “manually generated licenses” and “generating a new key”, are you referring to creating a new key with the “Add New” button on the “License Keys” page, or manually generating a new key using a specific generator with the “Generate” button on the “Generators” page?

    Thread Starter mennovink

    (@mennovink)

    I am referring to the ‘generate’ button on the generators page. I have found that the ‘add new’ button on the licenses page allows/requires me to fill out all the information that doesn’t necessarily conform to any generator’s settings.
    So Generators -> Generate -> choose generator / amount 1 / status delivered / choose product.
    This generates a license key for the correct product, in the correct format (6parts 4chars in my case). It generates a license using the “Valid for” field. Usually when a license is delivered through the shop it fills in the “Expires at” field.
    My intended use-case is to generate a license for a user without requiring him to register or complete an order.

    @mennovink Generate a key with status set to “Sold” (NOT “Delivered”) and see if it works.

    Thread Starter mennovink

    (@mennovink)

    Thanks for the help, that works ??

    Ye that’s what I expected. For now, using your current workflow for generating license keys manually, just generate them with a “sold” status, then manually change it to “delivered” after the key has been created.

    IMO I would consider this a bug; since a license key has to be sold before it can be delivered, creating a license key with an initial status of “delivered” should pass the same checks it would if the status was “sold” during the license generation.

    Note to devs (bug report): The conditional statement in the insertGeneratedLicenseKeys function only sets the $expiresAt field if $status == LicenseStatus::SOLD.

    Proposed change to logic:

    
    // includes/integrations/woocommerce/Controller.php:199
    if ($generator->getExpiresIn() && ($status == LicenseStatus::SOLD || $status == LicenseStatus::DELIVERED)) {
    //...
    

    @steliokontos Thanks for pointing it out Stelio, we will fix it in the next update.

    @haseeb0001 no problem. Would you like me to open a PR with the change?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Generate license with expiration date’ is closed to new replies.