Automatically complete free orders

I would like to autocomplete $0.00 orders.

I created a free plan and every time someone signs up, the order keeps processing. In this case I would like to complete automatically, because it is $0.00.

Please try this PHP snippet

add_action(
	'woocommerce_thankyou', 
	function($order_id) {
		// Get order.
		$order = wc_get_order( $order_id );

		if ( ! $order || ! $order->get_meta( 'hp_vendor' ) ||  floatval($order->get_total()) > 0) {
			return;
		}
		
		$order->update_status( 'completed' );
	},
	1000
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.