Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="<?php echo esc_url( add_query_arg( 'eddtickets_process', 1, edd_get_checkout_uri() ) ); ?>"
- class="cart" method="post"
- enctype='multipart/form-data'>
- <table width="100%" class="tribe-events-tickets">
- <?php
- global $edd_options;
- $is_there_any_product = false;
- $is_there_any_product_to_sell = false;
- ob_start();
- foreach ( $tickets as $ticket ) {
- $product = edd_get_download( $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 ( ! TribeEDDTickets::is_stock_left( $product->ID ) || ( 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 "<tr>";
- echo "<td width='75' class='edd'>";
- if ( TribeEDDTickets::is_stock_left( $product->ID ) ) {
- echo '<input type="number" class="edd-input" min="0" name="quantity_' . $ticket->ID . '" value="0"/>';
- // How many remain?
- $limit = (int) get_post_meta( $product->ID, '_stock', true );
- $sold = (int) edd_get_download_sales_stats( $product->ID );
- $remaining = absint( $limit - $sold );
- if ( $remaining > 0 ) echo
- " <span class='edd_tickets_remaining'> $remaining tickets still available! </span> ";
- $is_there_any_product_to_sell = true;
- } else {
- echo "<span class='tickets_nostock'>" . esc_html__( 'Out of stock!', 'tribe-eddtickets' ) . "</span>";
- }
- echo "</td>";
- echo "<td nowrap='nowrap' class='tickets_name'>";
- echo $ticket->name;
- echo "</td>";
- echo "<td class='tickets_price'>";
- echo edd_price( $product->ID );
- echo "</td>";
- echo "<td class='tickets_description'>";
- echo $ticket->description;
- echo "</td>";
- echo "</tr>";
- }
- }
- $contents = ob_get_clean();
- if ( $is_there_any_product ) {
- ?>
- <h2 class="tribe-events-tickets-title"><?php _e( 'Tickets', 'tribe-eddtickets' );?></h2>
- <?php echo $contents; ?>
- <?php if ( $is_there_any_product_to_sell ) : ?>
- <?php
- $color = isset( $edd_options[ 'checkout_color' ] ) ? $edd_options[ 'checkout_color' ] : 'gray';
- $color = ( $color == 'inherit' ) ? '' : $color;
- ?>
- <tr>
- <td colspan="4" class='eddtickets-add'>
- <button type="submit" class="edd-submit button <?php echo $color; ?>"><?php esc_html_e( 'Add to cart', 'tribe-eddtickets' );?></button>
- </td>
- </tr>
- <?php
- endif;
- }
- ?>
- </table>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement