Support » Plugin: WC Duplicate Order » Stock not updated when duplicated

  • Resolved vitalseeds

    (@vitalseeds)


    The stock in woo is not updated when the order is duplicated, this is a function that i really need any chance of help with this?

    Thanks

    Fred

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jamie Gill

    (@patchgill)

    Hi Fred,

    hanks for using my plugin! You are right I think this maybe a change in Woocommerce recently from what I have read as the plugin is running ‘wc_reduce_stock_levels()’.

    It seems the payment status changes are now not allowing this function to run.

    I will see what I can find out.

    Cheers
    J

    Hi Jamie,

    now ‘wc_reduce_stock_levels()’ checks if the stock has already been reduced for every order item (with the ‘_reduced_stock’ item meta) and if the stock reduction has already been fired on the order (with the ‘_order_stock_reduced’ post meta).

    This is how i’ve fixed the issue:

    // Reset stock reduction for new order items
    foreach ( $order->get_items() as $item ) {
    $item->delete_meta_data( ‘_reduced_stock’ );
    }

    // Reset stock reduction for new order
    update_post_meta( $order_id, ‘_order_stock_reduced’, wc_bool_to_string( false ) );

    // Reduce Order Stock
    wc_reduce_stock_levels( $order_id );

    // Set status to on hold as payment is not received
    $order->update_status( ‘payment-pending’ );

    Plugin Author Jamie Gill

    (@patchgill)

    Hi Giovan,

    Seem to work like a charm nice fix. I will implement this and try get this released for you.

    Thanks
    J

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.