Search
 
SCRIPT & CODE EXAMPLE
 

PHP

auto complete order paid

add_action( 'woocommerce_payment_complete_order_status', 'wc_auto_complete_paid_order', 10, 3 );
function wc_auto_complete_paid_order( $status, $order_id, $order ) {
    return 'completed';
}
Comment

auto complete order paid1

add_action( 'woocommerce_thankyou', 'wc_auto_complete_paid_order', 20, 1 );
function wc_auto_complete_paid_order( $order_id ) {
    if ( ! $order_id )
        return;
    
    // Get an instance of the WC_Product object
    $order = wc_get_order( $order_id );
    
    // No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods.
    if ( in_array( $order->get_payment_method(), array( 'bacs', 'cod', 'cheque', '' ) ) ) {
        return;
    } 
    // For paid Orders with all others payment methods (paid order status "processing")
    elseif( $order->has_status('processing') ) {
        $order->update_status( 'completed' );
    }
}
Comment

auto complete order paid2

/**
 * AUTO COMPLETE PAID ORDERS IN WOOCOMMERCE
 */
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_paid_order', 10, 1 );
function custom_woocommerce_auto_complete_paid_order( $order_id ) {
    if ( ! $order_id )
    return;

    $order = wc_get_order( $order_id );

    // No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods.
    if ( ( 'bacs' == get_post_meta($order_id, '_payment_method', true) ) || ( 'cod' == get_post_meta($order_id, '_payment_method', true) ) || ( 'cheque' == get_post_meta($order_id, '_payment_method', true) ) ) {
        return;
    } 
    // For paid Orders with all others payment methods (with paid status "processing")
    elseif( $order->get_status()  === 'processing' ) {
        $order->update_status( 'completed' );
    }
}
Comment

auto complete order paid3

add_action( 'woocommerce_payment_complete', 'wc_auto_complete_paid_order', 20, 1 );
function wc_auto_complete_paid_order( $order_id ) {
    if ( ! $order_id )
        return;

    // Get an instance of the WC_Product object
    $order = wc_get_order( $order_id );

    // No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods.
    if ( in_array( $order->get_payment_method(), array( 'bacs', 'cod', 'cheque', '' ) ) ) {
        return;
    // Updated status to "completed" for paid Orders with all others payment methods
    } else {
        $order->update_status( 'completed' );
    }
}
Comment

auto complete order paid1

add_filter('woocommerce_order_item_needs_processing', '__return_false',999);
Comment

PREVIOUS NEXT
Code Example
Php :: symfony send exception 
Php :: get auth guard user laravel 
Php :: how to check request method in php 
Php :: OroCRM Custom Bundle is loaded? 
Php :: Eagar loading,parent child relationship,Sub relationship in laravel 
Php :: Rewrite .php file without .php extension with .htaccess ULTIMATE SOLUTION 
Php :: what returns livewire mount 
Php :: termii curl otp 
Php :: doctrine findby regex 
Php :: laravel How to apply Eloquent where() to child in hasMany() relationship 
Php :: eager loading set limit to relationship 
Php :: Access app.php values laravel 
Php :: dont allow this command to every one set in meddlware laravel 
Php :: Downward half-Pyramid Pattern of Star 
Php :: PHP OOP - Static Methods 
Php :: laravel where has relation 
Php :: install PHP extension "amqp" not found, please install it 
Php :: php to html 
Php :: Add class to menu anchors 
Php :: one to many laravel 
Php :: php post data empty 
Php :: what does ? do in php 
Php :: find string lenght in php 
Php :: enable cors cakephp 
Php :: How to protect your website from DDos Attack? 
Php :: add method to laravel blade 
Java :: jlabel text center 
Java :: change java version command line debian 
Java :: junit 5 dependency maven 
Java :: how to clear the screen by pressing a key in java 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =