تابع ووکامرسی wc_cancel_unpaid_orders لغو کردن تمامی سفارشات پرداخت نشده
تابع ووکامرسی wc_cancel_unpaid_orders – لغو کردن تمامی سفارشات پرداخت نشده فروشگاه بعد از مدت مشخص شده
Syntax – سینتکس
wc_cancel_unpaid_orders();
Usage – نحوه استفاده
if ( !function_exists( 'wc_cancel_unpaid_orders' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php'; } // NOTICE! Understand what this does before running. $result = wc_cancel_unpaid_orders();
Defined – محل تعریف
/includes/wc-order-functions.php
function wc_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 ) ) { $order->update_status( 'cancelled', __( 'Unpaid order cancelled - time limit reached.', woocommerce ) ); } } } wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' ); wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' ); }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر