See docs.woothemes.com/document/template-structure/
You’d need to loop over the items before this line and then set the email_heading to something else:
https://github.com/woothemes/woocommerce/blob/master/templates/emails/customer-processing-order.php#L26
Actually, I have already modified the woocommerce cart and the customer can only buy one product at a time. So there’s no need to loop for checking the items. What I need is a conditional code in the email template wherein it checks if the product is variable or simple.
Thanks
You still need a loop because thats how products are stored in the order.
$order->get_items();
This returns an array of items.
$variable = false;
foreach ( $order->get_items() as $item ) {
$_product = $order->get_product_from_item( $item );
if ( $_product->is_type( 'variable' ) ) {
$variable = true;
}
}
Where should I put this Mike?
would this work?
$order->get_items();
foreach ( $order->get_items() as $item ) {
$_product = $order->get_product_from_item( $item );
if ( $_product->is_type( 'variable' ) ) {
$email_heading= "New Customer Order Confirmed";
} else {
$email_heading= "New Customer Order";
}
}
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
Tried my code above, and it seems that it does not work. Any other suggestions Mike?
This code was to be adapted and put into the template files I referenced. Order does not exist in your code/hook.
What do you mean Mike? I think the order is working on my email template since it has the following hook:
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
Sorry misread what you’re doing.
Which file did you place the code in? Processing affects customer processing emails, no others. So you’ll need to update a few if you want to affect other emails. The code looks ok aside from the first line is not needed.
wp-content/plugins/woocommerce/templates/emails/customer-processing-order.php
I did put it on the php file above. But it does not change anything on the header.
Which order email are you checking though? This is only the one to customer after payment.
Which order email are you checking though?
what do you mean by that Mike?
I also edited and I added this block of code on the customer-completed-order.php and it works but only outputs the ELSE condition. Of course I have been testing it on the simple and variable products.
foreach ( $order->get_items() as $item ) {
$_product = $order->get_product_from_item( $item );
if ( $_product->is_type( 'variable' ) ) {
_e( "Your order has been received and is now being <b>PROCESSED</b>. Your order details are shown below for your reference:", 'woocommerce' );
} else {
_e( "Your order has been received and is <b>CONFIRMED</b>. Your order details are shown below for your reference:", 'woocommerce' );
}
}
what could be the problem that I am facing Mike?
Try:
$_product->is_type( 'variation' )
wow, it is now working ! thank you so much Mike. I wonder what’s the difference between variation and variable? 🙂
Variable is the parent. Variation is the child.