0

In wordpress/woocommerce config, we use the "COD" payment method to place an order, then our office staff manually sets a shipping quote, and sends a second email to the customer with their order, a shipping quote, and a payment link where they can now pay with their credit card. After they pay, we need to send them a different email than the COD "completion" email. I have custom email templates in my child theme, and thought this has been working, but I now see after the COD and the CC payment, they get the same thank you email, which is very confusing. I'd prefer to do this without a plugin, but this is rather urgent, so I'll entertain any suggestions.

0

Well, I answered my own question. It is somewhat idiosyncratic, but will help those who also want to add a shipping quote manually on their woocommerce site, or otherwise add conditional code to woocommerce emails.

We do this because many of our orders cannot be shipped by a simple carrier, but must be prepared for truck shipments either loose or on pallets. These often require us to send quotes to several truck companies before we find the best deal.

In any case, I was able to edit the customer-processing-order.php email template (in my child theme, of course) and add a conditional test to see the payment method used. When it is "cod" (which looks to the customer as "Submit order for shipping quote" on the front end) they get an appropriate message. Otherwise they see that their order has been released to manufacturing.

The conditional portion (With a couple of lines of the standard woocommerce template for context) is:

    do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

    <?php /* translators: %s: Customer first name */ ?>
    <p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>

    <p><?php 
    if ($order->get_payment_method() == cod)
      {
      printf( esc_html__( 'Order #%s', 'woocommerce' ), esc_html( $order->get_order_number() ) );
      printf('
    Thank you for your order, which has now been sent to our office staff to find the best method to ship this order to you. <strong>Within 1 business day we will send you an updated invoice including a shipping quote and link</strong> which will take you to our credit card payment page. If you have any questions, special requests, or need to have this order expedited, please call our office during business hours at xxx-xxx-xxxx (or 1-800-xxxxxxx)');  
      }
    else
      {
      printf( esc_html__( 'Order #%s is now released to manufacturing', 'woocommerce' ), esc_html( $order->get_order_number() ) );
      printf('
    <strong>Thank you for your payment</strong>, which has been received successfully. Below is the complete order. Please review it for errors or omissions. If you have any further questions call our office during business hours at xxx-xxx-xxxx (or 1-800-xxxxxxx)'); 
      }
    ?></p>
  • I'm actually surprised that I didn't have to put cod in quotes. That was an oversight, but it clearly works fine. I've tested this both on my dev platform, and the production site. It works with quotes as well. I have a lot to learn about php, it seems... – Edward S Bernstein Jun 18 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.