I am trying to develop a plugin that send the customer a “gift receipt” upon completing an order. I have everything working perfectly except I am unable to strip the price from the emails. When I try to edit the email-order-items.php template and remove the price column then the emails come in blank.
Specifically this is for downloadable products so the download links no longer show when I make any edits to the email-order-items file. And I would only want it to strip the price from the gift receipt emails not the other emails.
What I have done:
in my plugin I call on a email template “customer-gift-receipt.php” which is pretty much the same as “customer-processing-order.php” that comes package with Woocommerce.
In the file there is this line that brings in the email-order-items template and shows the links and price
<?php echo $order->email_order_items_table( $order->is_download_permitted(),
true, ($order->status=='processing') ? true : false ); ?>
This is the email-order-items template.
No matter what I do I cannot seem to get those prices stripped from just the customer-gift-receipt.php
emails. Specifically it is this line in the above template:
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;">
<?php echo $order->get_formatted_line_subtotal( $item ); ?>
</td>
I tried creating a duplicate of the email-order-items template and removing that line then calling it in my plugin and that did not work. I also tried copying the email-order-items template inside of the customer-gift-receipt.php
file in the appropriate section and that failed as well. I had to define $items = $order->get_items();
when I tried copying email-order-items
directly into the customer-gift-receipt
template for it to somewhat work.
So can anyone suggest a way for me to strip the prices out of my customer-gift-receipt templates?
I have checked through these links:
Class WC_Email_Customer_Processing_Order
UPDATE:
I just found this link which should help me bring in email_order_items_table
outside of the class: https://gist.github.com/mikejolley/1965842
When I try to add the above code in my customer-email-receipt
template and place an order I get this error:
Fatal error: Class 'order_item_meta' not found in
.../.../.../.../woocommerce/emails/customer-gift-receipt.php on line 41"
Disable e-mail order items table from e-mail template and copy the function as a custom function into your theme.
I had to remove download and variations which causes *Fatal Error with Class ‘order_item_meta’* error. So your custom function will look like: