• Resolved galjega

    (@galjega)


    Hi!

    I can’t change the order payment method from admin panel (edit order) after the order is placed, even if I set it manually to the desired value (bacs).

    add_action( ‘woocommerce_process_shop_order_meta’, ‘woocommerce_process_shop_order’, 10, 2 );

    function woocommerce_process_shop_order ( $order_id ) {
    // no luck
    update_post_meta( $order_id, ‘_payment_method’, ‘bacs’ );

    // also no luck
    $order = wc_get_order( $order_id );
    $order->set_payment_method( WC()->payment_gateways->payment_gateways()[‘bacs’]);
    $order->save();

    // even if I delete it, woocommerce always add original value (cod) at the end of the meta data array
    delete_post_meta( $order_id, ‘_payment_method’);
    }

    Any ideas? Thanks, Goran

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Fernando a11n

    (@fhaps)

    Automattic Happiness Engineer

    It sounds like you are having trouble manually editing the payment method registered on an oder.

    Just to make sure, have you tried updating it from the dropdown in the order? https://cld.wthms.co/XA9DN2

    You get that dropdown to show by editing the billing fields in the order. I just tested it on a site of my own, and I was able to change the method. It remained there after updating the order with the changes.

    Thread Starter galjega

    (@galjega)

    Hi Fernando,

    Somehow editing the billing details was hidden. You are right, I can change the payment method from here.

    Unfortunatelly, it doesn’t change the payment method title. It still shows the old title…I tried with:

    $payment_method_title = get_post_meta( $order->id, ‘_payment_method_title’, true );

    and with:

    $payment_method_title = $order->get_payment_method_title();

    So, I have to grab the title with this:

    $payment_method_title = WC()->payment_gateways->payment_gateways()[$payment_method]->title;

    Thank you for suggestion!

    All the best!

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi there,

    I’m glad you were able to get this sorted!

    I’m going to mark this thread as Resolved now. Please feel free to open a new one if you have any further questions.

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t change payment method after order is placed’ is closed to new replies.