Skip to main content
St Louis

Back to all posts

How to Get Woocommerce Last Order Amount?

Published on
3 min read
How to Get Woocommerce Last Order Amount? image

Best Woocommerce Plugins to Buy in November 2025

1 The Ultimate WordPress & WooCommerce Handbook: From Setup to Success in Online Selling

The Ultimate WordPress & WooCommerce Handbook: From Setup to Success in Online Selling

BUY & SAVE
$12.90
The Ultimate WordPress & WooCommerce Handbook: From Setup to Success in Online Selling
2 Building E-Commerce Solutions with WooCommerce - Second Edition

Building E-Commerce Solutions with WooCommerce - Second Edition

BUY & SAVE
$38.99
Building E-Commerce Solutions with WooCommerce - Second Edition
3 WordPress WooCommerce: Tienda online con WooCommerce (Spanish Edition)

WordPress WooCommerce: Tienda online con WooCommerce (Spanish Edition)

BUY & SAVE
$35.90 $37.90
Save 5%
WordPress WooCommerce: Tienda online con WooCommerce (Spanish Edition)
4 WordPress WooCommerce: Webshop met WooCommerce (Dutch Edition)

WordPress WooCommerce: Webshop met WooCommerce (Dutch Edition)

BUY & SAVE
$24.99
WordPress WooCommerce: Webshop met WooCommerce (Dutch Edition)
5 MeplLivs Warmers Pluggable Fragrance Warmer- Decorative Plug-in for Warming Scented Candle (Golden)

MeplLivs Warmers Pluggable Fragrance Warmer- Decorative Plug-in for Warming Scented Candle (Golden)

  • HANDMADE ELEGANCE ENHANCES ANY ROOM DECOR BEAUTIFULLY.
  • ENJOY LONG-LASTING FRAGRANCE WITHOUT FLAMES OR POLLUTION.
  • COMPACT DESIGN FITS ANY VERTICAL OUTLET, ADDING WARMTH EFFORTLESSLY.
BUY & SAVE
$11.99
MeplLivs Warmers Pluggable Fragrance Warmer- Decorative Plug-in for Warming Scented Candle (Golden)
6 Saillong Wall Fragrance Plug in with Night Light Compatible with Bath and Body Works WallFlower Fragrance, with Rotary Plug Design Essential Oil Diffuser Plug for Home, Office (2 Pack)

Saillong Wall Fragrance Plug in with Night Light Compatible with Bath and Body Works WallFlower Fragrance, with Rotary Plug Design Essential Oil Diffuser Plug for Home, Office (2 Pack)

  • DUAL FUNCTIONALITY: ENJOY SOOTHING SCENTS AND NIGHTLIGHT IN ONE!

  • VERSATILE DESIGN: ROTATES FOR USE IN ANY OUTLET, SPILL-FREE OPERATION.

  • EASY TO USE: QUICK SETUP ENSURES INSTANT FRAGRANCE ENJOYMENT ANYTIME!

BUY & SAVE
$15.99
Saillong Wall Fragrance Plug in with Night Light Compatible with Bath and Body Works WallFlower Fragrance, with Rotary Plug Design Essential Oil Diffuser Plug for Home, Office (2 Pack)
+
ONE MORE?

To get the last order amount in WooCommerce, you can use the get_total() function on the order object. First, you need to retrieve the last order using the wc_get_orders() function and sorting it by date in descending order. Then, you can access the total amount of the order using the get_total() function. This will give you the amount of the last order made in WooCommerce.

How to access the last order amount using WooCommerce templates?

You can access the last order amount using WooCommerce templates by adding the following code snippet to your template file:

$order = wc_get_orders( array( 'numberposts' => 1, 'orderby' => 'date', 'order' => 'DESC', ) );

if ( $order ) { echo 'Last order amount: ' . $order[0]->get_total(); }

This code snippet retrieves the last order made in WooCommerce and then retrieves the total amount of that order using the get_total() method. You can place this code in your template file wherever you want to display the last order amount.

What is the method for calculating the last order amount in WooCommerce?

To calculate the last order amount in WooCommerce, you can use the following method:

  1. Retrieve the last order ID from the database: You can query the database to find the ID of the most recent order. You can use the wc_get_orders() function to get a list of orders sorted by date, and then retrieve the ID of the first order in the list.
  2. Get the order total amount: Once you have the ID of the last order, you can use the get_total() method to retrieve the total amount of the order.

Here is an example code snippet:

// Get the last order ID $orders = wc_get_orders( array( 'limit' => 1, 'orderby' => 'date', 'order' => 'DESC', ) ); $last_order_id = ! empty( $orders ) ? $orders[0]->get_id() : 0;

// Get the total amount of the last order if ( $last_order_id ) { $last_order = wc_get_order( $last_order_id ); $last_order_amount = $last_order->get_total();

echo 'The last order amount is: ' . $last\_order\_amount;

} else { echo 'No orders found.'; }

This code snippet will retrieve the total amount of the last order placed in WooCommerce and display it. You can use this code in your theme's functions.php file or in a custom plugin.

What is the shortcode for displaying the last order amount in WooCommerce?

The shortcode for displaying the last order amount in WooCommerce is:

[woocommerce_order_last_order_amount]

What is the function for extracting the last order amount in WooCommerce?

To extract the last order amount in WooCommerce, you can use the following function:

function get_last_order_amount() { $last_order = wc_get_orders( array( 'limit' => 1, 'orderby' => 'date', 'order' => 'DESC', ) );

if ( ! empty( $last\_order ) ) {
    $last\_order\_amount = $last\_order\[0\]->get\_total();
    return $last\_order\_amount;
} else {
    return false;
}

}

You can call this function in your theme files or anywhere you need to display or use the last order amount in your WooCommerce store.