I am using \"How can I get the latest order id in Woocommerce\" answer code that returns last order with a custom function get_last_order_id()
.
Updated: replaced
WC()->customer
bynew WC_Customer( get_current_user_id() );
for better compatibility.
The Class WC_Customer
Class include the get_last_order() method to get the last order for a customer (so you don't need anymore the custom function get_last_order_id()
from this answer thread).
So your code will be:
get_last_order();
$order_id = $last_order->get_id(); // Get the order id
$order_data = $last_order->get_data(); // Get the order unprotected data in an array
$order_status = $last_order->get_status(); // Get the order status
?>
get_items() as $item ) : ?>
- get_name(); ?>
Tested and works.
Note: Now to "receive the contents of the cart in addition to the latest order from the current user", you will have to ask a new question with more details, one question at the time please.
Related: