Problem z anulowanymi platnosciami
-
Panstwa wtyczka ustawia status zamowien jako Pending payment. Problem pojawia się przy niedokonczonych/porzuconych platnosciach. Wtedy taka porzucona platnosc i tak robi w sklepie zamowienie i sciaga produkty ze stanow. Pomimo, ze po wyznaczonym czasie taka nieudana platnosc przechodzi w status anulowane, to nie przywraca to stanow magazynowych. Zmowienie staje sie anulowane, a produkty w nim sa dalej sciagniete ze stanow.
Probowalam uzyc tego kodu, zeby przywrocic stany magazynowe dla anulowanych zamowien, ale nie dziala:
remove_filter( 'woocommerce_cancel_unpaid_orders', 'wc_cancel_unpaid_orders' ); add_filter( 'woocommerce_cancel_unpaid_orders', 'override_cancel_unpaid_orders' ); function override_cancel_unpaid_orders() { $held_duration = get_option( 'woocommerce_hold_stock_minutes' ); if ( $held_duration < 1 || 'yes' !== get_option( 'woocommerce_manage_stock' ) ) { return; } $data_store = WC_Data_Store::load( 'order' ); $unpaid_orders = $data_store->get_unpaid_orders( strtotime( '-' . absint( $held_duration ) . ' MINUTES', current_time( 'timestamp' ) ) ); if ( $unpaid_orders ) { foreach ( $unpaid_orders as $unpaid_order ) { $order = wc_get_order( $unpaid_order ); if ( apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === $order->get_created_via(), $order ) ) { //Cancel Order $order->update_status( 'cancelled', __( 'Unpaid order cancelled - time limit reached.', 'woocommerce' ) ); //Restock foreach ($order->get_items() as $item_id => $item) { // Get an instance of corresponding the WC_Product object $product = $item->get_product(); $qty = $item->get_quantity(); // Get the item quantity wc_update_product_stock($product, $qty, 'increase'); } } } } wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' ); wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' ); }
Potrzebuje, zeby przy anulowaniu sie takiego nieoplaconego zamowienia automatycznie produkty wracaly na stan. Czy mozecie mi cos doradzic?
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Problem z anulowanymi platnosciami’ is closed to new replies.