Do Something After The WooCommerce Order is Completed

WooCommerce comes with a built-in hook called woocommerce_order_status_completed, which allows you to execute a function as soon as the order is completed.

Quick Tip : How to Use WP-PageNavi With WooCommerce?

Within your function you an also create an instance of WC_Order class to access the details of your last order.

<?php
//hook into WooCommerce after the order is completed
add_action( 'woocommerce_order_status_completed', 'do_something' );
function do_something($order_id) {
        //creating an order object to access details of last order.
	$order = new WC_Order( $order_id );
	
}

 

0 Comments

Leave a Comment.