Created
September 20, 2018 18:29
-
-
Save Super-Chama/86e4e551c6f5a6e7bae18c05cbc2f239 to your computer and use it in GitHub Desktop.
WP-Eventer Plugin shortcode to get remaining tickets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to theme's functions.php
Usage:
[tickets_count id="xx" count="xx"]
id= Product id
count= Number of tickets issued