Hi, I am trying to add the Woocommerce automatic order complete PHP code in my technogy child functions.php theme but WordPress stops working, I tried with a plugin called “code snippets but seems don’t have any effect, can you help me please?
The code I found on the woo-commerce website (https://woocommerce.com/document/automatically-complete-orders/) is this:
/**
* Auto Complete all WooCommerce orders.
*/
add_action( ‘woocommerce_thankyou’, ‘custom_woocommerce_auto_complete_order’ );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$order->update_status( ‘completed’ );
}