Comments HUYA started the conversationOctober 15, 2020 at 2:39pmHi there :)I was wondering if there is the following option:Automatically hide a recurring event when the ticket "Quantity limit per event occurrence" is reached. Basically hide the event when its "sold out".Much love to your product! 894Zhivko repliedOctober 19, 2020 at 3:30pmHi,There's no such option at the moment. I've written small code that extends the default filters behaviour. It should remove the events with sold out tickets from the listings.Place the code in your theme or child-theme functions.php file: /** * STEC MOD: remove events with sold tickets */add_action('wp_footer', function() { global $post; if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'stachethemes_ec')) { return; } ?> <script type="text/javascript"> (function ($) { $(function () { if (typeof $.stecExtend === 'undefined') { return; } $.stecExtend(function (m) { var filtered = []; $.each(m.calData.filterGetEvents, function () { let event = this; let offset = this.repeat_time_offset ? parseInt(this.repeat_time_offset, 10) : 0; let hasTickets = false; if (this.bookable_products.length <= 0) { return true; // continue; } $.each(this.bookable_products, function () { let totalQty, perEvQty, avQty, sold; totalQty = isNaN(parseInt(this.stock_quantity, 10)) ? 9999 : parseInt(this.stock_quantity, 10); perEvQty = isNaN(parseInt(this.qty_limit_per_event, 10)) ? totalQty : parseInt(this.qty_limit_per_event, 10); avQty = Math.min(totalQty, perEvQty); sold = this.tickets_sold[offset] ? this.tickets_sold[offset] : 0; if (!isNaN(parseInt(this.qty_limit_per_event, 10))) { if (sold < avQty) { hasTickets = true; return false; // break } } else { if (0 < avQty) { hasTickets = true; return false; // break } } }); if (false !== hasTickets) { filtered.push(event); } }); m.calData.filterGetEvents = filtered; }, 'beforeReturnGetEvents'); }); })(window.jQuery); </script> <?php}); Stachethemes Developer Sign in to reply ...
Hi there :)
I was wondering if there is the following option:
Automatically hide a recurring event when the ticket "Quantity limit per event occurrence" is reached. Basically hide the event when its "sold out".
Much love to your product!
Hi,
There's no such option at the moment.
I've written small code that extends the default filters behaviour. It should remove the events with sold out tickets from the listings.
Place the code in your theme or child-theme functions.php file:
Stachethemes Developer