Skip to content

Instantly share code, notes, and snippets.

@Super-Chama
Created September 20, 2018 18:29
Show Gist options
  • Save Super-Chama/86e4e551c6f5a6e7bae18c05cbc2f239 to your computer and use it in GitHub Desktop.
Save Super-Chama/86e4e551c6f5a6e7bae18c05cbc2f239 to your computer and use it in GitHub Desktop.
WP-Eventer Plugin shortcode to get remaining tickets.
//Product Sales Shortcode
function ticket_count_shortcode( $atts ) {
$atts = shortcode_atts( array( 'id' => null, 'count' => 0), $atts, 'bartag' );
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
$_product = wc_get_product( $atts['id'] );
$tickets_left = $atts['count']-($_product->get_total_sales());
}
return $tickets_left;
}
add_shortcode( 'tickets_count', 'ticket_count_shortcode' );
@Super-Chama
Copy link
Author

Add to theme's functions.php
Usage:
[tickets_count id="xx" count="xx"]
id= Product id
count= Number of tickets issued

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment