Empty WooCommerce cart after successful order

WooCommerce by default empties cart when an order is placed successfully. But there are some plugins and/or themes, which alter this default functionality, and keep items on cart even after an order was completed with successful payment. While this can be useful for more sales, it is also can be very confusing for end customer.

So our objective is to empty the cart, entirely, when an order is placed successfully. We will use woocommerce_new_order hook to achieve this. This hook is triggered when a new order is created. We could also use woocommerce_thankyou hook, one of the most popular hooks. But this has some problem. If you have a redirect enabled after successful order, this hook won’t run. Because it only runs on order-received page.

function careless_empty_cart_on_successful_order() {
    global $woocommerce;
add_action( 'woocommerce_new_order', 'careless_empty_cart_on_successful_order' );

Code goes in the functions.php file of your active theme.