Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom payment gateway and it is out of theme folder. it's located "/" root..

anyway, I got proper wc variable and completed payment. and then I need to make the status completed.

I have 2 questions,

  1. after payment has been completed, do I just need to update (or change) pending to completed? or do I need to do more things to complete woo commerce payment?

  2. I put these hooks for changing status to "completed". but none of them is working.

    $order_id=28447;
    
         include $_SERVER["DOCUMENT_ROOT"]."/wp-load.php"; // this is only for out of wp page.
    
    
    mysite_woocommerce_order_status_completed($order_id);
    
    mysite_woocommerce_payment_complete($order_id);
    
    add_filter ('woocommerce_payment_complete_order_status', 'my_change_status_function');
    
    
    function my_change_status_function ($order_id) { 
        global $woocommerce;
    $order = new WC_Order($order_id);
    //Do whatever additional logic you like beforeā€¦.
    
    return 'completed';
    }
    
    add_action( 'woocommerce_payment_complete_order_status', 'my_post_order_status_change_function' );
    
    
    
    function mysite_woocommerce_order_status_completed( $order_id ) {
    
        error_log( "Order complete for order $order_id", 0 );
        echo "heoooooo!!!Order complete for order $order_id";
    }
    add_action( 'woocommerce_payment_complete', 'mysite_woocommerce_order_status_completed' );
    
    
    
    
    
    // woocommerce_payment_complete_order_status
    // woocommerce_payment_complete_order_status
    // woocommerce_order_status_completed
    // woocommerce_payment_complete
    
    
    add_action( 'woocommerce_order_status_completed', 'my_function' );
    /*
     * Do something after WooCommerce sets an order on completed
     */
    //my_function($order_id);
    
    function my_function($order_id) {
    
        echo "aaaaaaaaaaa";
    
        // order object (optional but handy)
        $order = new WC_Order( $order_id );
    
        // do some stuff here
    
    }
    
    
    
    function mysite_woocommerce_payment_complete( $order_id ) {
    
        error_log( "Payment has been received for order $order_id", 0 );
    
        echo "ok11";
    
    }
    
    add_action( 'woocommerce_payment_complete','mysite_woocommerce_payment_complete' );
    

None of them is working on the custom payment completed page.

I even tried to put in functions.php or header.php. but nothing changed These are what I have found others blogs. everybody says it works fine.

What I have been missed? any tips?

btw, the status is "pending" now.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.