The store offers physical products and workshop classes. There are many product categories for physical products. There is ONE product category for workshop classes, called "ticket". I want the email invoice to display "Workshop Instructions/Policies" (location of venue; cancellation policy; etc.) if the order includes a workshop class and "Return Policies" if it includes physical products.
In other words, if any product in the order has a product category id corresponding to "ticket", I need to show Workshop Instructions/Policies. And if any product in the order has a product category id corresponding to ANYTHING OTHER THAN "ticket", I need to display "Return Policies".
I "sort of" have this working.
The problem is that I can only get this to work by displaying the policies ABOVE the Order Items table in the email. The customer wants the policies at the BOTTOM, which makes sense.
The code that works is at the bottom of the email-order-items.php template. Inside the foreach loop in that file, I have this:
$nwb_product_cat_ids[] = wc_get_product_cat_ids( $item['product_id'] );
After the close of the foreach loop is where I do some tweaking (reducing the multidimensional array to a simple array and removing duplicates) and then evaluating which policies need to be displayed.
I have defined the workshop ("ticket") product category in the variable $nwb_ticket_cat_id. Here are the two if loops:
if ( in_array( $nwb_ticket_cat_id, $nwb_product_cat_ids_reduced ) ) {
$nwb_show_policy_class = true;
}
if ( count($nwb_product_cat_ids_reduced) > 1
||
!in_array( $nwb_ticket_cat_id, $nwb_product_cat_ids_reduced ) ) {
$nwb_show_policy_return = true;
}
Then I have this:
<?php if ( $nwb_show_policy_return ) : ?>
<p>Here is our return policy:</p>
<?php endif; ?>
<?php if ( $nwb_show_policy_class ) : ?>
<p>Here is our class policy:</p>
<?php endif; ?>
As I said, this works, but only by displaying the content ABOVE the order details table.
I've tried (rather blindly, I must admit) to utilize action hooks, to no avail.
Help wanted. I'm sure I need to provide more information and will do so gladly.