• Resolved teachingzeal

    (@teachingzeal)


    Is it possible to differentiate product keys for different products? Maybe something simple like adding a prefix for each separate product? Thanks

Viewing 1 replies (of 1 total)
  • Plugin Contributor 10Quality

    (@10quality)

    Hey, sorry for not responding this previously, we were working the new release and decided to respond you later.

    While the current version of the plugin does not provide this option in form of a wizard or form, you can surely achieve this using hooks.

    First, make sure to add a custom meta field where to store the product prefix, you can use WordPress “Advance Custom Fields” plugin to achieve this without much coding.

    Then implement the following hook.

    
    // Hook called before creating license key
    add_filter( 'woocommerce_license_key_meta_value', function( $license_key, $item, $product ) {
    
        // Get the product prefix, the following example uses ACF code
        $prefix = get_field( 'prefix', $product->get_id() );
    
        // Append prefix to code
        $license_key['code'] = $prefix . $license_key['code'];
    
        // Return data
        return $license_key;
    
    }, 10, 3 );
    
    • This reply was modified 6 years, 6 months ago by 10Quality.
    • This reply was modified 6 years, 6 months ago by 10Quality. Reason: Correction done to code shared
Viewing 1 replies (of 1 total)
  • The topic ‘differentiate products’ is closed to new replies.