Advertisement
Guest User

Modded Tickets.php

a guest
Apr 23rd, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.96 KB | None | 0 0
  1. <?php
  2. global $woocommerce;
  3. global $wootickets_no_show;
  4. global $wootickets_pricing;
  5.  
  6. $wootickets_pricing = array();
  7.  ?>
  8.  
  9. <form action="<?php echo esc_url( add_query_arg( 'wootickets_process', 1, $woocommerce->cart->get_cart_url() ) ); ?>"
  10.       class="cart" method="post"
  11.       enctype='multipart/form-data'>
  12.         <table width="100%" class="tribe-events-tickets">
  13.             <?php
  14.  
  15.             $is_there_any_product         = false;
  16.             $is_there_any_product_to_sell = false;
  17.  
  18.             $gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : " " . get_option( 'gmt_offset' );
  19.             $gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
  20.                
  21.             ob_start();
  22.             foreach ( $tickets as $ticket ) {
  23.  
  24.                 global $product;
  25.  
  26.                 if ( class_exists( 'WC_Product_Simple' ) ) {
  27.                     $product = new WC_Product_Simple( $ticket->ID );
  28.                 } else {
  29.                     $product = new WC_Product( $ticket->ID );
  30.                 }
  31.  
  32.                 $end_date = $ticket->end_date;
  33.                 if ( empty( $ticket->end_date ) ) {
  34.  
  35.                     $event_end_date = tribe_get_end_date();
  36.  
  37.                     if ( tribe_get_all_day( get_the_ID() ) )
  38.                         $event_end_date = date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( TribeDateUtils::endOfDay( $event_end_date ) ) );
  39.  
  40.                     $end_date = apply_filters( 'wootickets_default_end_date', $event_end_date, $ticket->ID );
  41.  
  42.                     if ( method_exists( 'DateTime', 'createFromFormat' ) ) {
  43.                         $end_date = DateTime::createFromFormat( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $end_date );
  44.                     } else {
  45.                         $end_date = new DateTime( date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $end_date ) ) );
  46.                     }
  47.  
  48.                     if ( !empty( $end_date ) )
  49.                         $end_date = $end_date->format( 'Y-m-d g:i a' );
  50.                 }
  51.                 $end_date = strtotime( $end_date . $gmt_offset );
  52.  
  53.                 $start_date = null;
  54.                 if ( !empty( $ticket->start_date ) )
  55.                     $start_date = strtotime( $ticket->start_date . $gmt_offset );
  56. //              if ( !empty( $ticket->start_date ) ) {
  57. //                  $start_date = DateTime::createFromFormat( get_option( 'date_format' ), $ticket->start_date );
  58. //                  $start_date = strtotime( $start_date->format( 'Y-m-d' ) . $gmt_offset );
  59. //              }
  60.  
  61.  
  62.                 if ( ( !$product->is_in_stock() ) || ( empty( $start_date ) || time() > $start_date ) && ( time() < $end_date ) ) {
  63.  
  64.                     $is_there_any_product = true;
  65.  
  66.                     echo sprintf( "<input type='hidden' name='product_id[]' value='%d'>", $ticket->ID );
  67.  
  68.                     echo "<tr>";
  69.                     echo "<td width='75' class='woocommerce'>";
  70.  
  71.  
  72.                     if ( $product->is_in_stock() ) {
  73.  
  74.                         woocommerce_quantity_input( array( 'input_name'  => 'quantity_' . $ticket->ID,
  75.                                                            'input_value' => 0,
  76.                                                            'min_value'   => 0,
  77.                                                            'max_value'   => $product->backorders_allowed() ? '' : $product->get_stock_quantity(), ) );
  78.  
  79.                         $is_there_any_product_to_sell = true;
  80.  
  81.                     } else {
  82.                         echo "<span class='tickets_nostock'>" . esc_html__( 'Out of stock!', 'tribe-wootickets' ) . "</span>";
  83.                     }
  84.                     echo "</td>";
  85.  
  86.                     echo "<td nowrap='nowrap' class='tickets_name'>";
  87.                     echo $ticket->name;
  88.                     echo "</td>";
  89.  
  90.                     echo "<td class='tickets_price'>";
  91.                     echo $product->get_price_html();
  92.                     echo "</td>";
  93.  
  94.                     echo "<td class='tickets_description'>";
  95.                     echo $ticket->description;
  96.                     echo "</td>";
  97.  
  98.                     echo "</tr>";
  99.                 }
  100.  
  101.             }
  102.             $contents = ob_get_clean();
  103.             if ( $is_there_any_product ) {
  104.                 ?>
  105.                 <h2 class="tribe-events-tickets-title"><?php _e( 'Tickets', 'tribe-wootickets' );?></h2>
  106.                 <?php echo $contents; ?>
  107.                 <?php if ( $is_there_any_product_to_sell ) { ?>
  108.                     <tr>
  109.                         <td colspan="4" class='woocommerce'>
  110.  
  111.                             <button type="submit"
  112.                                     class="button alt"><?php esc_html_e( 'Add to cart', 'tribe-wootickets' );?></button>
  113.                         </td>
  114.                     </tr>
  115.                     <?php
  116.                 }
  117.             }
  118.             ?>
  119.  
  120.         </table>
  121.  
  122. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement