Home › Forums › Ticket Products › Event Tickets Plus › Ticket stock not reducing… with automatic "complete" order status
- This topic has 15 replies, 4 voices, and was last updated 9 years, 2 months ago by
Pascal Feltrin.
-
AuthorPosts
-
January 30, 2017 at 1:52 am #1226051
Pascal Feltrin
ParticipantHello,
Since I use Event Ticket Plus I have this problem of ticket’s stock not reducing. It takes a lot of time and energy as I need to regularly correct the amount of the stock of the many events I manage (and sometimes people bought tickets for events that were already full :/ ).I think I configured everything I could so that make PayPal, Woocommerce and my website communicate well…
(Also, i’m using global stock)I follow those similar threads but no problem solving answers did emerge :
↑↑↑ This last one is the closest of my situation. George has had the good idea to suggest to try to disabling “auto-completion” functions. I did this during a week and there were absolutely no stock problem!
But by selling a lot of event tickets everyday of the week, I can’t stay behind my computer all the time and manually complete every orders…So the problem might be linked to this auto-completion function ? Is this useful to get closer to a solution ^^ ?
Thanks for your time,
ClementJanuary 30, 2017 at 9:03 pm #1226624Cliff
MemberHi, Clement. Sorry you’re experiencing this.
We do have a bug currently logged for when using PayPal via WooCommerce. Is that also your situation?
For example, if you have both PayPal and Check payment methods enabled in your WooCommerce settings and someone pays via Check while the autocomplete order setting is enabled, then does the issue still happen?
January 31, 2017 at 12:15 am #1226677Pascal Feltrin
ParticipantHi Cliff, thanks for your answer,
The only payment method enabled is in deed PayPal (but no check payment enabled).
January 31, 2017 at 7:04 pm #1227265Cliff
MemberPlease temporarily enable Check or some other payment method, have the autocomplete order setting enabled, and do a test ticket purchase with a WooCommerce ticket. Then see if the issue is specific to PayPal or the autocomplete order setting.
Thank you.
February 1, 2017 at 6:40 am #1227463Pascal Feltrin
ParticipantOk, 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 informationsI 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: completedThe line “Aborting, Order #7597 is already complete” seems weird…
February 1, 2017 at 1:46 pm #1227813Cliff
MemberThank you SO much for your effort here and the extra troubleshooting information; I shared it with the developer currently assigned to this high-priority bug.
Just today, our development team finished researching and here’s the result:
After further review, this issue does not appear to be a bug. Rather it is the expected behaviour of WooCommerce and of orders placed via the PayPal payment gateway. In fact, if you test the same scenario out using just WooCommerce–i.e., using a regular WooCommerce product and without activating any of our plugins–you should be able to experience the same thing. Ideally, if PayPal’s IPN is functioning properly (which likely won’t work on localhost sites and some server configurations), then WooCommerce’s stock should automatically reduce.
When completing orders manually, for instance, the requirement for you to also update inventory manually is expected and deliberate. If you have further questions on this please don’t hesitate to let us know, however in many cases the WooCommerce team will be better able to assist especially if your question relates to the operation of WooCommerce in general and is not specific to tickets or our ticketing plugins.
We’re sorry for any confusion and for any delay in providing this update and, again, if we can help further definitely let us know!
February 3, 2017 at 5:28 am #1228849Pascal Feltrin
ParticipantHi, 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
February 3, 2017 at 3:02 pm #1229227Cliff
MemberThanks for your understanding.
Here are a few functions that may be helpful to you:
- tribe_events_has_tickets
- tribe_events_count_available_tickets
- tribe_events_has_unlimited_stock_tickets
- tribe_events_has_soldout
- tribe_events_partially_soldout
Please review the code for each at https://github.com/moderntribe/event-tickets/blob/4.4.1/src/template-tags/tickets.php and let me know if you have any follow-up questions.
February 6, 2017 at 1:44 am #1229827Pascal Feltrin
ParticipantHi, 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.
-
This reply was modified 9 years, 2 months ago by
Pascal Feltrin.
February 7, 2017 at 12:38 pm #1230835Cliff
MemberPlease provide the entire contents of your PHP snippet, along with where it is located, and I’ll see if I can assist further here.
February 8, 2017 at 1:49 am #1231166Pascal Feltrin
ParticipantHi, 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
-
This reply was modified 9 years, 2 months ago by
Pascal Feltrin.
February 8, 2017 at 10:01 pm #1231864Cliff
MemberThanks so much for sharing for other users’ benefit.
Kudos!
February 9, 2017 at 5:59 pm #1232546George
ParticipantHello!
I wanted to share the news that we released a Maintenance Release today that includes some improvements with how our plugins integrate with WooCommerce’s order statuses.
You should be able to see this update in your wp-admin Updates page. You can learn more about the release here → https://theeventscalendar.com/maintenance-release-events-calendar-4-4-2-event-tickets-4-4-2-premium-add-ons/
You can also check out a new Knowledgebase article about these specific improvements and how to use them on your site → https://theeventscalendar.com/knowledgebase/woocommerce-specific-ticket-settings/
Cheers!
GeorgeFebruary 14, 2017 at 12:24 am #1234317Pascal Feltrin
ParticipantHi,
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 : )
-
This reply was modified 9 years, 2 months ago by
Pascal Feltrin.
February 14, 2017 at 6:37 pm #1234914Cliff
MemberHeck yeah!
I didn’t even know this fix/feature was upcoming.
I think it was the solution to the problem you and others have brought up for some time now, and I’m very glad to hear this is more understandable and customizable for your needs.
Sorry about the extra effort here, but I hope this solution lasts a good, long time for you and others!
-
AuthorPosts
- The topic ‘Ticket stock not reducing… with automatic "complete" order status’ is closed to new replies.
