Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $woocommerce;
- global $wootickets_no_show;
- global $wootickets_pricing;
- $wootickets_pricing = array();
- ?>
- <form action="<?php echo esc_url( add_query_arg( 'wootickets_process', 1, $woocommerce->cart->get_cart_url() ) ); ?>"
- class="cart" method="post"
- enctype='multipart/form-data'>
- <table width="100%" class="tribe-events-tickets">
- <?php
- $is_there_any_product = false;
- $is_there_any_product_to_sell = false;
- $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 );
- ob_start();
- 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 );
- }
- $end_date = $ticket->end_date;
- if ( empty( $ticket->end_date ) ) {
- $event_end_date = tribe_get_end_date();
- if ( tribe_get_all_day( get_the_ID() ) )
- $event_end_date = date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( TribeDateUtils::endOfDay( $event_end_date ) ) );
- $end_date = apply_filters( 'wootickets_default_end_date', $event_end_date, $ticket->ID );
- if ( method_exists( 'DateTime', 'createFromFormat' ) ) {
- $end_date = DateTime::createFromFormat( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $end_date );
- } else {
- $end_date = new DateTime( date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $end_date ) ) );
- }
- if ( !empty( $end_date ) )
- $end_date = $end_date->format( 'Y-m-d g:i a' );
- }
- $end_date = strtotime( $end_date . $gmt_offset );
- $start_date = null;
- if ( !empty( $ticket->start_date ) )
- $start_date = strtotime( $ticket->start_date . $gmt_offset );
- // if ( !empty( $ticket->start_date ) ) {
- // $start_date = DateTime::createFromFormat( get_option( 'date_format' ), $ticket->start_date );
- // $start_date = strtotime( $start_date->format( 'Y-m-d' ) . $gmt_offset );
- // }
- if ( ( !$product->is_in_stock() ) || ( empty( $start_date ) || time() > $start_date ) && ( time() < $end_date ) ) {
- $is_there_any_product = true;
- echo sprintf( "<input type='hidden' name='product_id[]' value='%d'>", $ticket->ID );
- echo "<tr>";
- echo "<td width='75' class='woocommerce'>";
- if ( $product->is_in_stock() ) {
- woocommerce_quantity_input( array( 'input_name' => 'quantity_' . $ticket->ID,
- 'input_value' => 0,
- '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__( 'Out of stock!', 'tribe-wootickets' ) . "</span>";
- }
- echo "</td>";
- echo "<td nowrap='nowrap' class='tickets_name'>";
- echo $ticket->name;
- echo "</td>";
- echo "<td class='tickets_price'>";
- echo $product->get_price_html();
- echo "</td>";
- echo "<td class='tickets_description'>";
- echo $ticket->description;
- echo "</td>";
- echo "</tr>";
- $wootickets_pricing[] = $product->get_price();
- }
- }
- $contents = ob_get_clean();
- if ( $is_there_any_product ) {
- ?>
- <h2 class="tribe-events-tickets-title"><?php _e( 'Tickets', 'tribe-wootickets' );?></h2>
- <?php echo $contents; ?>
- <?php if ( $is_there_any_product_to_sell ) { ?>
- <tr>
- <td colspan="4" class='woocommerce'>
- <button type="submit"
- class="button alt"><?php esc_html_e( 'Add to cart', 'tribe-wootickets' );?></button>
- </td>
- </tr>
- <?php
- }
- }
- ?>
- </table>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement