Re: email order confirmation to third party
I need something similar and I'm having a hard time figuring it out. The website is for a medical office that sells nutritional supplements. They have a referral program, and the customer chooses the referring provider from a drop-down during the sign-up process. The client wants an order confirmation email to also go to the referring provider upon checkout. Any ideas on how to do this?
Thank you in advance for your time.
Re: email order confirmation to third party
Change the SQL query to retrieve the appropriate destination email address, instead of doing customer-group lookup.
Re: email order confirmation to third party
Quote:
Originally Posted by
DrByte
Change the SQL query to retrieve the appropriate destination email address, instead of doing customer-group lookup.
Am I going in the right direction?
PHP Code:
<?php
/**
* observer class to send custom extra order emails to referring clinic/doctor
*
* @package classes
* @copyright Copyright 2003-2010 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: class.sendReferralOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
class sendReferralOrderNotices extends base {
/** constructor method !
*
* Attach observer class to the global $zco_notifier and watch for a single notifier event.
*/
function sendReferralOrderNotices() {
$this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
/**
* Set the email subject line for the messages being sent to the external supplier
* Use EMAIL_TEXT_SUBJECT for the default subject, or replace with 'My Custom Subject Line' instead.
*/
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
}
/** Actual Method that does the desired activity
*
* Called by observed class when any of the notifiable events occur
*
* @param object $class
* @param string $eventID
*/
function update(&$class, $eventID, $paramsArray = array()) {
global $db;
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;
//$group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
$referral_query = $db->Execute("SELECT sources.sources_email AS sources_email
FROM sources INNER JOIN customers ON sources.sources_id = customers.customers_info_source_id
WHERE customers.customers_id = '" . (int)$_SESSION['customer_id'] . "'");
//if (!$referral_query->EOF && $referral_query->fields['customers_group_pricing'] == $this->specialReferralId) {
if (!$referral_query->EOF) {
$this->specialReferralEmailAddress = $referral_query->fields['sources_email'];
zen_mail('', $this->specialReferralEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
}
}
Sorry I'm relatively new to zen cart. Thank you for your help.
Re: email order confirmation to third party
Looks good, assuming the SQL query pulls back the right data.
Re: email order confirmation to third party
Quote:
Originally Posted by
DrByte
Looks good, assuming the SQL query pulls back the right data.
Do you know of any reason this wouldn't work with v1.3.8? I can't get it to send an email even when I hard code the recipient email address in the zen_mail function in the class file. Upgrading is not an option at this time.
This was the only difference in order.php:
PHP Code:
//$zco_notifier->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL');
$zco_notifier->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL', array($zf_insert_id, $email_order, $extra_info, $html_msg));
Re: email order confirmation to third party
Is this will work with 1.5.1?
I need to add something really similar to specific products. Maybe as an attribute...? The store will sell many products but one of them is a membership card that will need an approbation from clubs who are affiliated with the store. So on these specific products the customer should have to select his club in the buying process. Each club needs to be associated with an email adress wich will be used to send a copy of the email order confirmation. Then the club will have to reply to confirm that the customer is a member. Not sure how to implement this...
Re: email order confirmation to third party
Yes, you could rework all the code to focus on purchased attributes of specific products instead of customer-groups.
So, instead of testing whether the shopper is a member of a specific customer-group, test whether the $order->products array contains specific products, and whether the attributes sub-array contains the specific attribute you want to notify about. And then based on which attribute, send an email to the correspondingly appropriate email address.
Re: email order confirmation to third party
I see. Seems a hard work to "rework all the code" but should be doable. Thanks for the input, I'll try to figure it out. :thumbsup:
Re: email order confirmation to third party
I installed it and it's working like a charm, the way it's suppose to work. Beautiful job Dr! But I tested it before I make any modification and I realized that it unfortunately do not really do what I need...
I made the attributes with all the clubs in a dropdow list than, by testing the attribute as a customer I understood that the selected option really needs to be linked to the customer and should be relative to him instead of a product. I could add this drop down menu to the inscription page but it's only needed if the customer want to buy something in a specific product category member cards). To be a member of one of the affiliated clubs is an absolute prerequisite to buy a member card but for all other item the customer do not need it at all... Every year the customer will be able to renew his membership card with the info in his account.
And as explained, when the customer buy the member card, the selected club needs to be contacted for a confirmation that this customer is really one of its member. In a perfect world the club representant who will receive the confirmation request could just follow a link in the email that would bring him on a page where he'll be able to gives his confirmation by clicking on a button, then the order status would pass to the approved status and the customer + administration would receive the update email. That would be so nice!
Do you have an idea on how implement that?
Re: email order confirmation to third party
I'm glad you were able to use the code examples above to make things work as you initially described.
But your last question describes a situation that is a LOT more complex than the subject of this discussion thread. Your specialized needs should be discussed in a new thread: You need more than just email-confirmation-to-third-party ... I suspect you really need real-time verification of membership status from those 3rd-party sites *before* allowing the purchase to happen on *your* site.