-2

i try to show order id on checkout page in woocommerce_before_checkout_form action but i've no value

function action_woocommerce_before_checkout_form( $checkout ) { 
    var_dump(WC()->order->get_customer_id);
    echo'
    <div class="right-side">
        <div class="logo">';
        echo'
        </div>
        <div class="order-number"></div>
    </div>';
};      
// add the action 
add_action( 'woocommerce_before_checkout_form', 'action_woocommerce_before_checkout_form', 10, 1 ); 

any one have idea to get order id ?

1 Answers1

0

You may have misunderstood the workflow. An Order object is created only after checkout. So you won't get ID there. Actually what is the need of Order ID at that place ? Are you reffering to Customer ID or logged in user ID ?

If you are reffering to User ID, then you can add the following code inside the action

$current_user = wp_get_current_user();
$getmemid = $current_user->ID;
melvin
  • 2,571
  • 1
  • 14
  • 37