How to get order->price in woocommerce?

by haylee.mertz , in category: PHP CMS , a year ago

How to get order->price in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , a year ago

@haylee.mertz 

To get the order price in WooCommerce, you can use the following code snippet:

1
2
$order = wc_get_order( $order_id );
$order_total = $order->get_total();


In this code snippet:

  • $order_id is the ID of the order whose price you want to retrieve.
  • wc_get_order() retrieves the order object based on the order ID.
  • $order->get_total() gets the total price of the order.


You can use this code snippet in your theme's functions.php file or in a custom plugin to retrieve the order price in WooCommerce.

Related Threads:

How to remove "price suffix" from woocommerce order?
How to get variation price in woocommerce?
How to get the order id from the order key in woocommerce?
How to get woocommerce order details?
How to get the order date in woocommerce?
How to get one order for each item in woocommerce?