Pascal Feltrin

Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • Pascal Feltrin
    Participant

    Hi,

    Just wanted to say that this new system seems to solve my problem !
    (too bad i tried hard to solve the problem on my own, just days before ^^ )

    Great job anyway, thanks : )

    in reply to: Customize files in admin-views folder #1234310
    Pascal Feltrin
    Participant

    Hi, thanks or your answer.
    I just wanted to hide some elements and put some custom fields I created. Anyway It’s not a priority for me so It’s not a big deal. I managed to customize a little bit with CSS so it’s ok.

    Thanks,
    Clement

    Pascal Feltrin
    Participant

    Hi, sorry I didn’t dig enough to understand the code and the different functions I could use.

    I think I made it work now ^^

    Here is what I’ve done in tickets.php (the one for WooCommerce), see around line 20 and 57 :
    Of course It may not be the best/prettier way to do it…

    <?php
    /**
     * Renders the WooCommerce tickets table/form
     *
     * @version 4.2
     *
     * @var bool $global_stock_enabled
     * @var bool $must_login
     */
    global $woocommerce;
    
    $is_there_any_product         = false;
    $is_there_any_product_to_sell = false;
    
    ob_start();
    ?>
    
    <?php 
    /**
    * GET THE TOTAL OF TICKETS SOLD FOR THIS EVENT
    **/	
    foreach ( $tickets as $ticket ) {
    $total_sold += $ticket->qty_sold() + $ticket->qty_pending();
    }
    ?>
    
    <form action="<?php echo esc_url( $woocommerce->cart->get_cart_url() ) ?>" class="cart" method="post" enctype='multipart/form-data'>
    	<h2 id="reservation" class="tribe-events-tickets-title"><?php esc_html_e( 'Tickets', 'event-tickets-plus' ) ?></h2>
    
    	<table width="100%" class="tribe-events-tickets">
    		<?php
    		foreach ( $tickets as $ticket ) {
    			/**
    			 * @var Tribe__Tickets__Ticket_Object $ticket
    			 * @var WC_Product $product
    			 */
    			global $product;
    
    			if ( class_exists( 'WC_Product_Simple' ) ) {
    				$product = new WC_Product_Simple( $ticket->ID );
    			} else {
    				$product = new WC_Product( $ticket->ID );
    			}
    
    			if ( $ticket->date_in_range( current_time( 'timestamp' ) ) ) {
    
    				$is_there_any_product = true;
    				$data_product_id = 'data-product-id="' . esc_attr( $ticket->ID ) . '"';
    
    				echo sprintf( '<input type="hidden" name="product_id[]" value="%d">', esc_attr( $ticket->ID ) );
    
    				echo '<tr>';
    				
    				echo '<td class="woocommerce" ' . $data_product_id . '>';
    				
    		/**
    		* REAL GLOBAL STOCK CAPACITY
    		**/	
    		if ( $total_sold < 80 ) { 
    
    				if ( $product->is_in_stock() ) {
    					// Max quantity will be left open if backorders allowed, restricted to 1 if the product is
    					// constrained to be sold individually or else set to the available stock quantity
    					$max_quantity = $product->backorders_allowed() ? '' : $product->get_stock_quantity();
    					$max_quantity = $product->is_sold_individually() ? 1 : $max_quantity;
    					$original_stock = $ticket->original_stock();
    
    					// For global stock enabled tickets with a cap, use the cap as the max quantity
    					if ( $global_stock_enabled && Tribe__Tickets__Global_Stock::CAPPED_STOCK_MODE === $ticket->global_stock_mode()) {
    						$max_quantity = $ticket->global_stock_cap();
    						$original_stock = $ticket->global_stock_cap();
    					}
    
    					woocommerce_quantity_input( array(
    						'input_name'  => 'quantity_' . $ticket->ID,
    						'input_value' => 0,
    						'min_value'   => 0,
    						'max_value'   => $must_login ? 0 : $max_quantity, // Currently WC does not support a 'disable' attribute
    					) );
    
    					$is_there_any_product_to_sell = true;
    
    					$remaining = $ticket->remaining();
    
    					if ( $remaining ) {
    						?>
    						<span class="tribe-tickets-remaining">
    							<?php
    							echo sprintf( esc_html__( '%1$s available', 'event-tickets-plus' ),
    								'<span class="available-stock" ' . $data_product_id . '>' . esc_html( $remaining ) . '</span>'
    							);
    							?>
    						</span>
    						<?php
    					}
    
    					do_action( 'wootickets_tickets_after_quantity_input', $ticket, $product );
    				}
    		}
    		else {
    				echo '<span class="tickets_nostock">' . esc_html__( 'Out of stock!', 'event-tickets-plus' ) . '</span>';
    		}		
    				echo '</td>';
    
    				echo '<td class="tickets_name">';
    				echo $ticket->name;
    				echo '</td>';
    
    				echo '<td class="tickets_price">';
    				echo $this->get_price_html( $product );
    				echo '</td>';
    
    				echo '<td class="tickets_description">';
    				echo $ticket->description;
    				echo '</td>';
    
    				echo '</tr>';
    
    				if ( class_exists( 'Tribe__Tickets_Plus__Attendees_List' ) && ! Tribe__Tickets_Plus__Attendees_List::is_hidden_on( get_the_ID() ) ) {
    					echo '<tr class="tribe-tickets-attendees-list-optout">' . '<td colspan="4">' .
    						 '<input type="checkbox" name="optout_' . $ticket->ID . '" id="tribe-tickets-attendees-list-optout-woo">' .
    						 '<label for="tribe-tickets-attendees-list-optout-woo">' . esc_html__( 'Don\'t list me on the public attendee list', 'event-tickets' ) . '</label>' . '</td>' .
    						 '</tr>';
    				}
    
    				include Tribe__Tickets_Plus__Main::instance()->get_template_hierarchy( 'meta.php' );
    			}
    		}
    
    		if ( $is_there_any_product_to_sell ) {
    			?>
    			<tr>
    				<td colspan="4" class="woocommerce add-to-cart">
    					<?php if ( $must_login ): ?>
    						<?php include Tribe__Tickets_Plus__Main::instance()->get_template_hierarchy( 'login-to-purchase' ); ?>
    					<?php else: ?>
    						<button type="submit" name="wootickets_process" value="1"
    							class="button alt"><?php esc_html_e( 'Add to cart', 'event-tickets-plus' );?></button>
    							<a class="plus-infos-tarifs" title="Plus d'infos" href="http://www.hotclubjazzlyon.com/pratique/#tarifs"><i class="fa fa-info-circle" aria-hidden="true"></i> Plus d'informations sur les tarifs.</a>
    					<?php endif; ?>
    				</td>
    			</tr>
    			<?php
    		} ?>
    	</table>
    </form>
    
    <?php
    $content = ob_get_clean();
    if ( $is_there_any_product ) {
    	echo $content;
    } else {
    	$unavailability_message = $this->get_tickets_unavailable_message( $tickets );
    
    	// if there isn't an unavailability message, bail
    	if ( ! $unavailability_message ) {
    		return;
    	}
    
    	?>
    	<div class="tickets-unavailable">
    		<?php echo esc_html( $unavailability_message ); ?>
    	</div>
    	<?php
    }

    I tested it and it should work now !

    Thank you for your time

    Pascal Feltrin
    Participant

    Hi, thanks for your help.
    I would like to use “$sold” ($ticket->qty_sold();) but it looks like it doesn’t retrieve anything. I’m probably using it the wrong way…
    All I need to do would be something like :

    	if ($sold >= 100) {
    		do_whatever_i_want;
    		} 

    Sorry I’m not very familiar with PHP.

    Pascal Feltrin
    Participant

    Hi, thanks for your answer.

    I guess I will have to accept the natural behavior of WooCommerce which can be a little weird sometimes : )

    However I have an idea which could do the trick to solve my problem :

    I could keep the auto complete option enabled, which will lead to tickets stock not automatically reducing, but modify the template for tickets (ticket.php) so that after a certain amount of tickets sold for the event, the ticket form doesn’t display. For exemple, if the number of tickets sold is higher than a define number, the form is replaced by something else.

    I’m not asking you to customize this for me, but could you just tell me if there is a specified function that can retrieve the number of tickets sold for an event ?

    Thank you

    Pascal Feltrin
    Participant

    Ok, so I did that and it looks like the issue occurs only when paying with Paypal. No problem with the check payment method (the stock updated correctly).

    Here are some additional informations about my WooCommerce and PayPal configuration :
    • fsockopen/cURL is enabled
    • I have set an identity token for PayPal IPN
    • I have set the API identification informations

    I don’t know if this can help but here is the end of the PayPal event log (activated in WooCommerce), with the order paid with PayPal and with autocomplete option enabled :

    02-01-2017 @ 15:25:28 - Received valid response from PayPal
    02-01-2017 @ 15:25:28 - Found order #7597
    02-01-2017 @ 15:25:28 - Payment status: completed
    02-01-2017 @ 15:25:28 - Aborting, Order #7597 is already complete.

    And here with the autocomplete option disabled :

    02-01-2017 @ 15:32:18 - Received valid response from PayPal
    02-01-2017 @ 15:32:18 - Found order #7599
    02-01-2017 @ 15:32:18 - Payment status: completed

    The line “Aborting, Order #7597 is already complete” seems weird…

    Pascal Feltrin
    Participant

    Hi Cliff, thanks for your answer,

    The only payment method enabled is in deed PayPal (but no check payment enabled).

    Pascal Feltrin
    Participant

    Hi, i had the same problem and i solved it by installing and activating the plugin Events Calendar (i was only using Event Tickets Plus).
    This thread with a similar issue (https://theeventscalendar.com/support/forums/topic/woocommerce-product-page-not-showing-product-description-product-data-section) led me to that solution.

    However it doesn’t explain the origin of the problem, and I don’t really like to install and activate a (quite important) plugin, just to make another plugin run properly.

Viewing 8 posts - 1 through 8 (of 8 total)