Skip to content

Instantly share code, notes, and snippets.

@amostajo
Last active May 7, 2019 16:50
Show Gist options
  • Save amostajo/1b57569438bed2ad291649e3b0f05c5b to your computer and use it in GitHub Desktop.
Save amostajo/1b57569438bed2ad291649e3b0f05c5b to your computer and use it in GitHub Desktop.
Displaying license information
<?php
$license = get_option( WNT_FUNCTION );
if ( empty( $license ) ) {
// No license has been activated
// You can display the activation form
} else {
// Lets parse the license
$license = json_decode( $license );
// Echo license ACTIVATION ID
echo $license->activation_id;
// Echo ACTIVATION DATE
echo date( get_option( 'date_format' ), $license->activation_id );
// Echo expiration
if ( $license->expire )
echo date( get_option( 'date_format' ), $license->expire );
// HERE YOU CAN DISPLAY A DEACTIVATION BUTTON
}
add_filter(
'woocommerce_license_key_meta_value',
function( $meta, $item, $product, $order ) {
$duration = wc_get_order_item_meta( $item->get_id(), 'subscription_duration', true );
$meta['expire'] = $duration == 1
? strtotime( '+1 month' )
: strtotime( '+1 year' );
return $meta;
},
99,
4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment