Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Auto Complete all WooCommerce orders of a specific product.
- */
- 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 );
- foreach ( $order->get_items() as $item_id => $item_values ) {
- $product_id = $item_values->get_product_id();
- if ( $product_id == 326 ) {
- $order->update_status( 'completed' );
- return;
- }
- }
- }
Add Comment
Please, Sign In to add comment