Adding new mail template type

Onein - October 10, 2009 - 15:32
Project:e-Commerce
Version:5.x-3.6
Component:ec_mail
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I've been trying to get eCommerce to send emails to the customer and the store owner when a payment gateway indicates that a payment has been held for review (typically because the postcode provided by the customer doesn't match the one that their credit card company has for them).

I'm not a Drupal or eCommerce (or even PHP) expert, so I may not have tackled this in the best way. But my approach has been to duplicate store_send_invoice_email() to store_send_review_email(), and to modify accordingly. My payment gateway module can then call store_send_review_email() when appropriate.

Since store_send_invoice_email uses MAILVAR_CUSTOMER_INVOICE, I also searched for every occurrence of MAILVAR_CUSTOMER_INVOICE anywhere within the eCommerce module, and added corresponding code for MAILVAR_ORDER_REVIEW. Similarly for other code specific to customer invoices, i.e.

  • ECMAIL_TYPE_CUSTOMER_INVOICE -> ECMAIL_TYPE_ORDER_REVIEW
  • ec_mail_customer_invoice -> ec_mail_order_review
  • store_email_customer_invoice_subject -> store_email_order_review_subject
  • store_email_customer_invoice_body -> store_email_order_review_body

Having done so, I was able to create an order review template from the ec_mail administration pages.

However, this template isn't being picked up by my store_send_review_email() function. So while my (customer) emails are getting sent, they're completely empty!

It looks like the problem is that variable_get(MAILVAR_ORDER_REVIEW, 0) is not returning the id of this template. There's no record for ec_mail_order_review in the variables table either, so it seems that this is not getting set.

Where does this get set for the customer invoice template? I thought I had duplicated all the relevant customer invoice code for my order review, but I assume I must have missed something...

 
 

Drupal is a registered trademark of Dries Buytaert.