I am developing an eCommerce website on Wordpress using WooCommerce. I want to retrieve and display the 'Shipping Method' (i.e. Delivery or Collection etc.), that the customer had selected at the time of checkout, on the Order Confirmation page (i.e. after payment).
I am trying to do this using get_post_meta($post_id, $key, $single)
function. I am unable to do so as I don't know the $key value.
I tried the following code (within php tag):
echo get_post_meta( $order_id, 'shipping_method', true );
But it returns a blank value (no display on the page). I am assuming that I am using incorrect $key
.
I am open to suggestions to use some other (simpler) method also to achieve this.
One way is to simply go to the “Customers” page in your WordPress admin panel. From there, you can click on any customer to view their complete details. Another way to get customer details is through the WooCommerce REST API. This allows you to programmatically get information about customers, orders, etc.
WooCommerce offers three types of shipping methods by default. They include flat rate shipping, free shipping, and local pickup. Using flat rate shipping, you can ship items to your buyers at a flat or standard rate per item, order, or shipping class.
Since WooCommerce 3, if you want to get the shipping formatted method title(s), you can better use WC_Order
method get_shipping_method()
like:
// Get the WC_Order object from the Order ID
$order = wc_get_order( $order_id );
// Output the shipping method(s) formatted method title(s)
echo $order->get_shipping_method();
For other shipping item details see the following threads:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With