- <?php global $woocommerce; ?>
- <form action="<?php echo esc_url( add_query_arg( 'wootickets_process', 1, $woocommerce->cart->get_cart_url() ) ); ?>"
- class="event-tickets-cart" method="post"
- enctype='multipart/form-data'>
- <?php
- $is_there_any_product = false;
- $is_there_any_product_to_sell = false;
- ob_start();
- usort($tickets, 'tribe_wootickets_custom_sort');
- foreach ( $tickets as $ticket ) {
- global $product;
- if ( class_exists( 'WC_Product_Simple' ) ) {
- $product = new WC_Product_Simple( $ticket->ID );
- } else {
- $product = new WC_Product( $ticket->ID );
- }
- $gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : " " . get_option( 'gmt_offset' );
- $gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
- $end_date = null;
- if ( ! empty( $ticket->end_date ) ){
- $end_date = strtotime( $ticket->end_date . $gmt_offset );
- }else{
- $end_date = strtotime( tribe_get_end_date( get_the_ID(), false, 'Y-m-d G:i' ) . $gmt_offset );
- }
- $start_date = null;
- if ( !empty( $ticket->start_date ) )
- $start_date = strtotime( $ticket->start_date . $gmt_offset );
- if ( ( !$product->is_in_stock() ) || ( empty( $start_date ) || time() > $start_date ) && ( empty( $end_date ) || time() < $end_date ) ) {
- $is_there_any_product = true;
- echo sprintf( "<input type='hidden' name='product_id[]' value='%d'>", $ticket->ID );
- echo "<div class='ticket-sales'>";
- echo "<div class='tickets_quantity'>";
- if ( $product->is_in_stock() ) {
- woocommerce_quantity_input( array( 'input_name' => 'quantity_' . $ticket->ID,
- 'input_value' => 1,
- 'min_value' => 0,
- 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity(), ) );
- $is_there_any_product_to_sell = true;
- } else {
- echo "<span class='tickets_nostock'>" . esc_html__( 'SOLD OUT!', 'tribe-wootickets' ) . "</span>";
- }
- echo "</div>";
- $price_html = $this->get_price_html( $product );
- $new_price = preg_replace('/.00/', '', $price_html);
- echo "<span class='tickets_price'>" . $new_price . "</span>";
- echo "<div class='tickets_name'>" . $ticket->name . "</div>";
- echo "<div class='tickets_description'>" . $ticket->description . "</div>";
- echo "</div>";
- }
- }
- $contents = ob_get_clean();
- if ( $is_there_any_product ) {
- ?>
- <?php echo $contents; ?>
- <?php if ( $is_there_any_product_to_sell ) { ?>
- <div class='tickets_buynow'>
- <button type="submit"
- class="tickets_buybutton"><?php esc_html_e( 'Buy Now', 'tribe-wootickets' );?></button>
- </div>
- <?php
- }
- }
- ?>
- </form>
SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.