X
28655

Ticket #28655 Public [Closed]

Event ticket stock inventory not working properly

  • Hi,

    The event ticket stock inventory is not working properly. For example, i have an event ticket with remaining stock level at 7. User purchase a ticket with Paypal payment mode and when user click on Cancal on the Paypal payment page, the stock level auto-restock to 8 (which is not correct, it should reduce the stock to 6 first and then auto-restock to 7 when order is cancelled).

    It was working properly before i upgraded Event Ticket to version 1.4.1. My woocommer version is 2.6.14, EventOn version 2.5.1.

    Please help. Thanks

     

    BY: khongyp - Feb 19,2017 AT 10:27PM - 3 years ago
    • By: Ashish Rai Feb 20,2017 AT 7:42AM - Posted 3 years ago - #28697

      So, this occurs only when the purchase is made with paypal?

    • By: khongyp Feb 20,2017 AT 8:38PM - Posted 3 years ago - #28751

      This occurs only when the purchase is made with paypal because for cash or cheque payment, after user click on the “Place Order” button, the transaction is captured on the Woocommerce – Order and the stock level is reduced. So when admin change the order status to “Cancelled”, the stock level is auto-restock, which is correct. But with paypal, user can click on “cancel” on the paypal payment page which causes “Cancelled” order and trigger Auto-restock. When user reach the payment payment page, the order is captured in Woocommerce-Order but the stock level is not reduced. If user click on “cancel” on the paypal payment page, the order is consider “Cancelled” so the stock level is increased, which is not correct.

    • By: khongyp Feb 22,2017 AT 3:49AM - Posted 3 years ago - #28867

      Hi, any update on this? Thanks

    • By: Ashan Perera Feb 22,2017 AT 6:05PM - Posted 3 years ago - #28986

      Hi there sorry for the delay. SO here is whats happening here, stock count is 100% handled by woocommerce unless you have selected “Auto re-stock tickets…” in eventon ticket settings. SO try deactivating that if you have that on and give it a try.

      Because like said in the tooltips for that option if you have auto restock enable in WC as well this would double time the process and causing what you are seeing. But once this is deactivated in eventon settings, rest should be 100% handled with WC.

    • By: khongyp Feb 22,2017 AT 8:39PM - Posted 3 years ago - #29013

      Hi,

      We do not have auto restock enable in WC because Woocommerce has NO auto-restock feature and we do not install any auto-restock plugin either. We are only using the “Auto re-stock tickets” in eventon ticket settings.

      From what i see, the “Auto-restock tickets” feature in eventon ticket can only work with Cash payment or cheque payment. As for paypal payment because user can click on the “cancel” on the payment page, which woocommerce capture it as “Cancelled order” and so eventon ticket auto-restock the inventory.

      At first we were so happy that there is auto-restock feature in eventon ticket because this is what lacking in Woocommerce. Woocommerce has NO auto-restock feature. But now it seems eventon ticket auto-restock is not working properly either.

      Hope you can have a thorough test on this. Setup a paypal sandbox and do a test and you will see what i mean.

      Thanks for your help.

    • By: Ashan Perera Feb 23,2017 AT 10:25PM - Posted 3 years ago - #29165

      I see,

      Capture

      So if you look at the code you can see the tickets addon auto restock is only run when the WC order cancel and refund hook is run. SO another option I can suggest is to look for other 3rd party plugins for WC that does this for WC. If you can find something that does this for WC and then you can NOT use tickets restock option.

      So what I am saying is basically the auto restock is triggered by WC. So when WC cancel and order or refund is when its triggered and we have no control over how WC cancel those orders. Perhaps you may want to reach out to WC and see if they can give you some guidance

      Cheers!

       

    • By: khongyp Feb 26,2017 AT 9:45PM - Posted 3 years ago - #29384

      Hi, thanks for your reply.

      If user is paying via Paypal and the moment when Paypal payment open, Woocommerce immediately capture this transaction in Wooocommerc-Order with the order status as “Pending Payment” but stock is not reduced. So if user click on Cancel on the Paypal payment page, the order status change from “Pending Payment” to “Cancelled“.

      I found below auto-restore code is working because it is trigger only when the order status change from “Processing” (stock is reduced)  to “Cancelled” (‘woocommerce_order_status_processing_to_cancelled’).

      We prefer not to use third-party plugin or code because it is more difficult to manage multiple plugins. We really hope that Eventon auto-restock is working.

      We also found this post which said when WooCommerce reduces the stock for an order a post meta value ‘_order_stock_reduced’ is set to remember the stock is reduced for this order. Should EventOn check if the stock has actually been reduced for the order and skip restoring stock if post meta value ‘_order_stock_reduced’ is not set?

      https://wordpress.org/support/topic/only-restore-stock-when-inventory-for-order-is-reduced/ 

      https://github.com/woocommerce/woocommerce/blob/753014da5a6df243928e4b7baebb035300ab70ff/includes/abstracts/abstract-wc-order.php#L2470

       

      class Comfythemes_Woocommerce_Auto_Stock_Restore {

      function __construct() {
      add_action( ‘woocommerce_order_status_processing_to_cancelled’, array( $this, ‘restore_order_stock’ ), 10, 1 );
      add_action( ‘woocommerce_order_status_completed_to_cancelled’, array( $this, ‘restore_order_stock’ ), 10, 1 );
      add_action( ‘woocommerce_order_status_on-hold_to_cancelled’, array( $this, ‘restore_order_stock’ ), 10, 1 );
      add_action( ‘woocommerce_order_status_processing_to_refunded’, array( $this, ‘restore_order_stock’ ), 10, 1 );
      add_action( ‘woocommerce_order_status_completed_to_refunded’, array( $this, ‘restore_order_stock’ ), 10, 1 );
      add_action( ‘woocommerce_order_status_on-hold_to_refunded’, array( $this, ‘restore_order_stock’ ), 10, 1 );
      }
      public function restore_order_stock( $order_id ) {
      $order = new WC_Order( $order_id );

      if ( ! get_option(‘woocommerce_manage_stock’) == ‘yes’ && ! sizeof( $order->get_items() ) > 0 ) {
      return;
      }
      foreach ( $order->get_items() as $item ) {
      if ( $item[‘product_id’] > 0 ) {

      $_product = $order->get_product_from_item( $item );

      if ( $_product && $_product->exists() && $_product->managing_stock() ) {

      $old_stock = $_product->stock;
      $qty = apply_filters( ‘woocommerce_order_item_quantity’, $item[‘qty’], $this, $item );
      $new_quantity = $_product->increase_stock( $qty );
      do_action( ‘woocommerce_auto_stock_restored’, $_product, $item );
      $order->add_order_note( sprintf( __( ‘Item #%s stock incremented from %s to %s.’, ‘woocommerce’ ), $item[‘product_id’], $old_stock, $new_quantity) );
      $order->send_stock_notifications( $_product, $new_quantity, $item[‘qty’] );
      }
      }
      }
      }
      }
      new Comfythemes_Woocommerce_Auto_Stock_Restore();

    • By: Ashan Perera Feb 27,2017 AT 9:30AM - Posted 3 years ago - #29482

      Ok thank you for finding out about that part. But what is this function you pasted? it doesnt check for that _order_stock_reduced value. I will make a note of this but we will need to do some tests to make sure this will work before implementing it. But you are more than welcome to hook into our update_ticket_qty() and modify the code to support this in the mean time 🙂

    • By: khongyp Feb 27,2017 AT 10:43PM - Posted 3 years ago - #29566

      Hi, the function that i pasted doesn’t check for that _order_stock_reduced value. This function is working because it is triggered only when the order status change from “Processing” to “Cancelled” or from “Completed” to “Cancelled”.

      I just assume that we could check for _order_stock_reduced.

      Thanks for looking into this issue. However, we have one open ticket #14926 the stock inventory is not working for Repeating Event with “Manage capacity separate for each repeating event”. Hope you could looking into this issue too.

       

    • By: Ashan Perera Feb 28,2017 AT 10:43AM - Posted 3 years ago - #29641

      Ah yea that was you as well. I am going to close this ticket because they are both related issues and i will follow up in the other ticket. And in the future would greatly appreciate if you could minimize the duplicated issues so we can manage tickets easier 🙂

      Follow up : http://helpdesk.ashanjay.com/ticket/stock-level-not-increase-if-order-is-cancelled-or-refunded/

      Cheers!

You must login to reply to this ticket

HelpDesk

Welcome to EventON helpdesk.

EventON is the #1 Best selling event calendar plugin for WordPress websites in envato marketplace.

Checkout EventON