Guest User

Untitled

a guest
Jul 13th, 2014
385
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php global $woocommerce; ?>
  2.  
  3.  
  4. <form action="<?php echo esc_url( add_query_arg( 'wootickets_process', 1, $woocommerce->cart->get_cart_url() ) ); ?>"
  5. class="event-tickets-cart" method="post"
  6. enctype='multipart/form-data'>
  7.  
  8. <?php
  9.  
  10. $is_there_any_product = false;
  11. $is_there_any_product_to_sell = false;
  12.  
  13.  
  14. ob_start();
  15. usort($tickets, 'tribe_wootickets_custom_sort');
  16. foreach ( $tickets as $ticket ) {
  17.  
  18. global $product;
  19.  
  20. if ( class_exists( 'WC_Product_Simple' ) ) {
  21. $product = new WC_Product_Simple( $ticket->ID );
  22. } else {
  23. $product = new WC_Product( $ticket->ID );
  24. }
  25.  
  26. $gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : " " . get_option( 'gmt_offset' );
  27. $gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
  28.  
  29. $end_date = null;
  30. if ( ! empty( $ticket->end_date ) ){
  31. $end_date = strtotime( $ticket->end_date . $gmt_offset );
  32. }else{
  33. $end_date = strtotime( tribe_get_end_date( get_the_ID(), false, 'Y-m-d G:i' ) . $gmt_offset );
  34. }
  35.  
  36. $start_date = null;
  37. if ( !empty( $ticket->start_date ) )
  38. $start_date = strtotime( $ticket->start_date . $gmt_offset );
  39.  
  40.  
  41. if ( ( !$product->is_in_stock() ) || ( empty( $start_date ) || time() > $start_date ) && ( empty( $end_date ) || time() < $end_date ) ) {
  42.  
  43. $is_there_any_product = true;
  44.  
  45. echo sprintf( "<input type='hidden' name='product_id[]' value='%d'>", $ticket->ID );
  46.  
  47. echo "<div class='ticket-sales'>";
  48.  
  49. echo "<div class='tickets_quantity'>";
  50.  
  51. if ( $product->is_in_stock() ) {
  52.  
  53. woocommerce_quantity_input( array( 'input_name' => 'quantity_' . $ticket->ID,
  54. 'input_value' => 1,
  55. 'min_value' => 0,
  56. 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity(), ) );
  57.  
  58. $is_there_any_product_to_sell = true;
  59.  
  60. } else {
  61. echo "<span class='tickets_nostock'>" . esc_html__( 'SOLD OUT!', 'tribe-wootickets' ) . "</span>";
  62. }
  63. echo "</div>";
  64.  
  65.  
  66. $price_html = $this->get_price_html( $product );
  67. $new_price = preg_replace('/.00/', '', $price_html);
  68. echo "<span class='tickets_price'>" . $new_price . "</span>";
  69.  
  70. echo "<div class='tickets_name'>" . $ticket->name . "</div>";
  71.  
  72. echo "<div class='tickets_description'>" . $ticket->description . "</div>";
  73.  
  74.  
  75. echo "</div>";
  76.  
  77.  
  78. }
  79.  
  80. }
  81.  
  82. $contents = ob_get_clean();
  83. if ( $is_there_any_product ) {
  84. ?>
  85. <?php echo $contents; ?>
  86. <?php if ( $is_there_any_product_to_sell ) { ?>
  87.  
  88. <div class='tickets_buynow'>
  89. <button type="submit"
  90. class="tickets_buybutton"><?php esc_html_e( 'Buy Now', 'tribe-wootickets' );?></button>
  91. </div>
  92. <?php
  93.  
  94.  
  95. }
  96. }
  97.  
  98.  
  99.  
  100. ?>
  101.  
  102. </form>
RAW Paste Data