Order confirmation only for specified category
-
Hi,
I need to set order_confirmation on a specific product category.
What I tried:
1) I activated the option in germanized settings so that all orders have to be checked manually. After that I checked if the order contains a product with the specified category. If not I updated _order_needs_confirmation to false. It works fine but the emails which are sent are wrong.
2) I deactivated the option and checked if the product with the category is in the order. If yes I used WC_GZDP_Contract_Helper::instance()->set_order_confirmation_needed($order_id);. The emails are correct but the screen after the order is wrong and _order_needs_confirmation is also not set because I’m not able to confirm the order. What am I missing?add_action( 'woocommerce_checkout_update_order_meta', 'set_order_confirmation_needed_for_category', 1 ); function set_order_confirmation_needed_for_category( $order_id ) { $cat_check = false; foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $product = $cart_item['data']; if ( has_term( 'yoga-muenzen-ermaessigt', 'product_cat', $product->id ) ) { $cat_check = true; break; } } if ( $cat_check ) { //update_post_meta( $order_id, '_order_needs_confirmation', true ); WC_GZDP_Contract_Helper::instance()->set_order_confirmation_needed($order_id); } else { //update_post_meta( $order_id, '_order_needs_confirmation', false ); } }
Best,
Patrick
- The topic ‘Order confirmation only for specified category’ is closed to new replies.