• Resolved andyramone

    (@andyramone)


    Hello! I need to duplicate the information with the address (city and address) and the payment method in the order comment field. I figured out the address. Now I need to add a payment method:

    add_action('woocommerce_checkout_update_order_meta', 'after_checkout_create_order', 20, 2);
    function after_checkout_create_order( $order_id, $data ) {
        $order = wc_get_order($order_id);
        //Text "Delivery address"
        $text = __('Delivery address', 'woocommerce') . ': '. $_POST['billing_city'] . ', '. $_POST['billing_address_1'];
        // Customer's comment
        $note = $order->get_customer_note();
        // Combining a comment (if any) with the text
        $note = empty( $note ) ? $text : $note . '<br/>' . $text ;
        // Save
        $order->set_customer_note( $note );
        $order->save();
    }
    • This topic was modified 3 years, 11 months ago by andyramone.
    • This topic was modified 3 years, 11 months ago by andyramone.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Address and payment method in order notes’ is closed to new replies.