Advertisement
BakerMan

Ticket prices: modified tickets.php (WooTicket 1.0.1) part B

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