-
email order confirmation to third party
I am trying to figure out how I can get orders placed by customers belonging to a certain company or group to receive an order confirmation when the customer places an order.
Im a php newbie...
Is there a way to get zencart to do the following... (if customer is from company "ACME , or belongs to the "ACME" group then ...send the order confirmation to "[email protected]")... All other orders email site admim
Any help would be WONDERFUL!!!
-
Re: email order confirmation to third party
Admin >>> Email...
you can insert several addresses ( just follow the protocol shown ).
HOWEVER... sorting the email by the manner you propose may not be possible without some heavy coding
-
Re: email order confirmation to third party
Yes I know the Admin>Email Unfortunately that sends an email to as many emails as you want on EVERY order. What I need is only ACME customers to have an order notification sent to a third party.
-
Re: email order confirmation to third party
What if an order consists of SEVERAL products, of which ONE is from ACME and the others are from somewhere else?
-
Re: email order confirmation to third party
No the customer is from the company/organization "ACME" they can order whatever they want but I have to have the orders placed for this company/organization "ACME" sent to an administrative email from the ACME company for approval they then email be back a P.O. Number .... (the company has multiple locations) but a single approval person that issues P.O's for the invoice.
I just need the person who handle the P.O's to get the order when someone from that organization places an order.
-
Re: email order confirmation to third party
I posted the same request (third-party email by customer) in the Commercial Help Wanted forum a while back and got a couple of replies that didn't seem unreasonable, cost-wise. I wasn't able to follow up, but you might try there.
-
Re: email order confirmation to third party
Quote:
Originally Posted by
valnoren
No the customer is from the company/organization "ACME" they can order whatever they want but I have to have the orders placed for this company/organization "ACME" sent to an administrative email from the ACME company for approval they then email be back a P.O. Number .... (the company has multiple locations) but a single approval person that issues P.O's for the invoice.
I just need the person who handle the P.O's to get the order when someone from that organization places an order.
Ah... that's a little more straightforward, and I would suggest a solution that has nothing to do with zencart.
If you are using an email client (Outlook), build a RULE that will automatically forward YOUR receipt of the acme-specific confirmation, to the someone from Acme.
So... you will be receiving ALL order confirmations, regardless of the customer... Just configure Outlook to have a rule that says:
"If an order confirmation comes in with @acme.com in the whatever field, forward a copy to [email protected]"
I'm sure you will know how to set up rules in Outlook?
-
Re: email order confirmation to third party
Quote:
Originally Posted by
schoolboy
Ah... that's a little more straightforward, and I would suggest a solution that has nothing to do with zencart.
If you are using an email client (Outlook), build a RULE that will automatically forward YOUR receipt of the acme-specific confirmation, to the someone from Acme.
So... you will be receiving ALL order confirmations, regardless of the customer... Just configure Outlook to have a rule that says:
"If an order confirmation comes in with @acme.com in the whatever field, forward a copy to [email protected]"
I'm sure you will know how to set up rules in Outlook?
LOL schoolboy I thought of that myself but the client had this set up in an old OScommerce site and wants it the same way for the new zencart site...
Its a long story. In short theres a special category of products which are password protected. for a certain group.
this group adds an item to shopping cart.
then clicks checkout and instead of continuing to the shipping /login page it goes to a special form page that sends the info to the main Org's headqurters that approve the order and send the order back to the client.
Screwy I know...
I have the old form page which will probably function in zencart but how to get from the shopping cart page to the special ordering page ????? so it sends the form to the Org's HQ is where Im stuck
-
Re: email order confirmation to third party
Sounds like a Government Department in a Banana Republic.
It may be an idea to get someone to look at the osCommerce code... while it will definitely NOT work in ZC, the functional parameters will be obvious to a knowledgeable coder and it may speed up the dev of a ZC version, and therefore be cheaper.
-
Re: email order confirmation to third party
valnoren, using Zen Cart v1.3.9x, it's very simple.
You could hard-code lotsa stuff into the orders class, or you could go with a more sophisticated approach using notifiers/observers as I've outlined below:
1. Edit /includes/classes/order.php and change just one line near the very end of the file:
Code:
$this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL');
becomes this:
Code:
$this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL', array($zf_insert_id, $email_order, $extra_info, $html_msg));
2. Create a new file with the following content:
/includes/classes/observers/class.sendGroupOrderNotices.php
Code:
<?php
/**
* observer class to send custom extra order emails to supplier based on customer group membership
*
* @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.sendGroupOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
class sendGroupOrderNotices extends base {
/** constructor method !
*
* Attach observer class to the global $zco_notifier and watch for a single notifier event.
*/
function sendGroupOrderNotices() {
$this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
/**
* Set the specialGroupId to the number of the customer-group assigned in your admin
*/
$this->specialGroupId = 1;
/**
* Set the proper email address for the additional copy of order confirmations to be sent to
*/
$this->specialGroupEmailAddress = 'noreply@mail_domain.com';
/**
* 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'] . "'");
if (!$group_query->EOF && $group_query->fields['customers_group_pricing'] == $this->specialGroupId) {
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
}
}
You can customize the section in red, as needed.
3. Create a new file with the following content:
/includes/auto_loaders/config.sendGroupOrderNotices.php
Code:
<?php
/**
* autoloader activation point for custom group order email notices
*
* @package initSystem
* @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: config.sendGroupOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
/**
* Autoloader to instantiate observer class
*/
$autoLoadConfig[90][] = array('autoType'=>'class',
'loadFile'=>'observers/class.sendGroupOrderNotices.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'sendGroupOrderNotices',
'objectName'=>'sendGroupOrderNotices');
-
Re: email order confirmation to third party
WOW DrByte you rock!! I was looking at that area but I was banging my head against the wall.I am going to try this today!
-
Re: email order confirmation to third party
Quote:
Originally Posted by
schoolboy
Sounds like a Government Department in a Banana Republic.
It may be an idea to get someone to look at the osCommerce code... while it will definitely NOT work in ZC, the functional parameters will be obvious to a knowledgeable coder and it may speed up the dev of a ZC version, and therefore be cheaper.
LOL thats funny because it is for a government organization!
-
Re: email order confirmation to third party
Hi,
I know I am trying to awake a very old thread, but this has been a great information from your side, and helped me a lot.
Now I have a question, what if I want emails to go to different email ids for different groups.
I am novice at any coding :(
-
Re: email order confirmation to third party
Quote:
Originally Posted by
kapil_sb
Hi,
I know I am trying to awake a very old thread, but this has been a great information from your side, and helped me a lot.
Now I have a question, what if I want emails to go to different email ids for different groups.
I am novice at any coding :(
Dr Byte,
I need your expertise advise on my problem.
I have used your observer and Notifiers , as adviced in this post earlier. This works like a Dream for me! Thanks very much.
Now I need this functionality for mutiple Group IDs for sending mail to different email ids.. Is there a way to change the above code and use it?
I tried using If statement but gives a blank page on opening my website, or 500 error.
Thanks!
-
Re: email order confirmation to third party
Try changing this:
Code:
if (!$group_query->EOF && $group_query->fields['customers_group_pricing'] == $this->specialGroupId) {
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
to this:
Code:
if (!$group_query->EOF) {
$this->specialGroupEmailAddress = '';
switch($group_query->fields['customers_group_pricing']) {
case '1':
$this->specialGroupEmailAddress = 'email_address_for_group_1@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
case '2':
$this->specialGroupEmailAddress = 'email_address_for_group_2@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
case '3':
$this->specialGroupEmailAddress = 'email_address_for_group_3@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
default:
}
if ($this->specialGroupEmailAddress != '')
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
And then customize the numbers and email addresses as needed.
-
Re: email order confirmation to third party
Dr Byte,
Thanks for all your valuable support.
-
Re: email order confirmation to third party
Sir one more question,
If I need to send mail to two or more email ids for same Group ID. In that case what shall I Do?
-
Re: email order confirmation to third party
Change this:
Code:
$this->specialGroupEmailAddress = 'email_address_for_group_3@e_mail.com';
to this:
Code:
$this->specialGroupEmailAddress = 'Name1<email_address_1@e_mail.com>, Name2<email_address_2@e_mail.com>';
-
Re: email order confirmation to third party
Quote:
Originally Posted by
DrByte
Try changing this:
Code:
if (!$group_query->EOF && $group_query->fields['customers_group_pricing'] == $this->specialGroupId) {
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
to this:
Code:
if (!$group_query->EOF) {
$this->specialGroupEmailAddress = '';
switch($group_query->fields['customers_group_pricing']) {
case '1':
$this->specialGroupEmailAddress = 'email_address_for_group_1@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
case '2':
$this->specialGroupEmailAddress = 'email_address_for_group_2@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
case '3':
$this->specialGroupEmailAddress = 'email_address_for_group_3@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
default:
}
if ($this->specialGroupEmailAddress != '')
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
And then customize the numbers and email addresses as needed.
Dr Byte ,
When I use this code, It throws my CSS out of order, and my website shifts completely to left.
Also all my center boxes also fall out of order.
Please help.
-
Re: email order confirmation to third party
You must use all the code, in context. Just that snippet alone won't work.
-
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.
-
Re: email order confirmation to third party
In an ideal world, yes. But only for this specific category of product. But in the real world I could live with the possibility to have to give back the customer's money if the confirmation fails. And with a price over 100$ the customers will probably never buy the card if they have to select a club in the list without being a member of one of them. But I'll follow your idea and start a new thread on my needs. Thanks for all the help and hope you'll be able to help me with this.
-
Re: email order confirmation to third party
Sorry for bugging you with this DrBytes but I worked the idea and I think this addon could do the work with some little modification, but I will surely need your help... So lets simplify that.
I added the double email confirmation addon (http://www.zen-cart.com/downloads.php?do=file&id=107), so that double check with the fact that it will be really clear in the product description that they have to be a member of the affiliated clubs listed + the fact that they will have to choose the club they are from in a list as an attribute to by the product + the fact that customers will have to pay like 100$ in the process for their member card... All that will certainly confirm that they take care of what they do. And if mistake happens we could refund them without any problem since we'll use Paypal, or have them becoming a member of one of the affiliated clubs. So, I consider the login confirmation fixed for now, I'll live with the result of this decision.
Now, the other problem was to have the email send to the third party selected by the attribute. That's what I would like to have explained, if you have the time. I suspect it will all be done in the config.xxxxxx.php file, so could it be possible to also ad a condition which could be something like "If the product, or one of the products is in the category #x, send the xxxxxx email to (adress linked to the atribute of this product)".
Also, in the same way the third email will have a specific subject, is it possible to have a specific email send to that third party? It could contain only the information that the club need, which would be the name, adress, phone and email.
With these modifications it will be quite perfect for my needs. ;)
-
Re: email order confirmation to third party
Yes, adjust the class file (not the config file) and add the custom logic required, by determining the attributes on each product, and taking action accordingly. The $class variable contains many strings and arrays of all the information you need about the present order and its products and their associated attributes. You can change subject-line strings and destination email address strings based on your findings.
-
Re: email order confirmation to third party
Ok, majority of the zencart layout problem was fixed (some still pending, posted elsewhere on the forum) so I'm now ready to work on this specific function to make it work. I will give time on this in the next few days and will try to make this to work before the weekend. I know I'll need help and I hope you'll be able to help me a little, through this. Regards.
-
Re: email order confirmation to third party
Well... I started from the start with this and from the moment I created the config.sendGroupOrderNotices.php file I get the blank page error an the main page. As soon as I remove this file Zencart came back. I retried this few times without any succes.
Man I didn't even tried to change the code... Here's my link again. http://www.fc4x4q.com/boutique Any clue on why it does that?
Thanks in advance for your time!
-
Re: email order confirmation to third party
Find out the actual error message and take action based on that. See: http://www.zen-cart.com/content.php?124-blank-page
-
Re: email order confirmation to third party
Thanks for the link. I found the issue. I misspelled the name of the file by forgetting the "s" at the end of config.sendGroupOrderNotices.php... what a dumb mistake. Had some difficulties ti fond time to work on this today... Now I'm back on the track. Took off at the job tomorrow so I'll work on this tonight and tomorrow like if my life was depending of it. I need to make this work for Sunday.
-
Re: email order confirmation to third party
Is there a way to get the exact table name in the DB? One of the frustration in this project is that I have to built this on a not fully accessible server... Since I don't have all the access I had to use some imagination. But first, here's the code I use in the file I called class.sendClubOrderNotices.php:
Code:
<?php
/**
* observer class to send custom extra order emails to supplier based on customer group membership
*
* @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.sendClubsOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
class sendClubsOrderNotices extends base {
/** constructor method !
*
* Attach observer class to the global $zco_notifier and watch for a single notifier event.
*/
function sendClubsOrderNotices() {
$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 = 'Demande de confirmation de membre par ' . 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 products_option_value_id from " . customers_basket_attributes . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
if (!$group_query->EOF) {
$this->ClubEmailAddress = '';
switch($group_query->fields['products_option_value_id']) {
case '6':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
case '9':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
case '10':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
case '12':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
default:
}
if ($this->ClubEmailAddress != '')
zen_mail('', $this->ClubEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
}
}
Off course, I also corrected the name of the config. file and his content. Note also that the class. file currently on the server has real email addresses in the code to test the differents options.
So, I was able to load the store without any blank page, which is great. :cool: I was also able to complete an order but after the payment on Paypal I get an error message on a blank page saying "WARNING: An Error occurred, please refresh the page and try again.". After a refresh the store loads up properly but I had this message in a red box:
Quote:
10415 Transaction refused because of an invalid argument. See additional error messages for details. - A successful transaction has already been completed for this token.
With a quick search on the Forum I found a thread where you suggest a problem linked to a miscalled table : http://www.zen-cart.com/showthread.p...04#post1028104 This makes a lot of sens to me since I can't be sure about the table name. I suspected that the error was from this SQL query:
Code:
$group_query = $db->Execute("select products_option_value_id from " . customers_basket_attributes . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
By looking in the logs I found this error which confirm my thoughts:
Code:
PHP Fatal error: 1146:Table 'fc41320205382856.customers_basket_attributes' doesn't exist :: select products_option_value_id from customers_basket_attributes where customers_id = '10' in /home/content/06/8442606/html/boutique/includes/classes/db/mysql/query_factory.php on line 120
The payment was received on the Paypal account but Paypal send an email about this 10415 error and didn't returned any info about the payment to ZenCart. So the order details of the admin stayed empty.
So, the question is, is there a way to get the exact name of the table from distance?
And off course, do you see any other error in that code?
-
Re: email order confirmation to third party
I was able to get access to the DB this morning, the server owner gave me the access. There was 2 error in the names, customers_basket_attributes is suppose to be zen_customers_basket_attributes and products_option_value_id is products_optionS_value_id. So I fixed them and it's working!! :laugh: Woohoo!!
Now, i'm trying to set a specific email that could be send to the clubs. They do not need all the information send in the checkout confirmation. I'll see if I can use the existant template and work it a little.
-
Re: email order confirmation to third party
Quote:
Originally Posted by
AlexThibo
There was 2 error in the names, customers_basket_attributes is suppose to be zen_customers_basket_attributes
FYI, that's why in ZC core we use predefined constants, like TABLE_CUSTOMERS_BASKET_ATTRIBUTES which will automagically include the "zen_" prefix if the store uses that prefix, or "fred_" if that's what's being used, or even nothing if the store isn't using any prefixes.
-
Re: email order confirmation to third party
Thanks for the addition of information.
-
Re: email order confirmation to third party
I was making some more testing than sometime it was working and some other time it didn't. Strange situation... So I found a problem in the code. In this part:
PHP Code:
<?php
function update(&$class, $eventID, $paramsArray = array()) {
global $db;
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;
$group_query = $db->Execute("select products_options_value_id from " . zen_customers_basket_attributes . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
if (!$group_query->EOF) {
$this->ClubEmailAddress = '';
switch($group_query->fields['products_option_value_id']) {
case '6':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
case '9':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
case '10':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
case '12':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par ' . STORE_NAME;
break;
default:
}
I'm trying to get the "products_options_value_id" in the "zen_customers_basket_attributes" but it's not logical since it's not in the basket that I need to look but in the order! In "zen_orders_products_attributes" in fact. The basket is getting empty after the transaction that why it wasn't working. I don figure why it works few times but It's logical if it doesn't
So instead of
Code:
Execute("select products_options_value_id from " . zen_customers_basket_attributes . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'")
I think I should ask for something more like
Code:
Execute("select products_options_values_id from " . zen_orders_products_attributes . " where orders_products_id = '" . (int)$_SESSION['orders_products_id'] . "' and where products_options_id = '8'")
Am I ok with this code? Does it make sens?
-
Re: email order confirmation to third party
I know everyone are very busy but I need help here please to have this query to work.
Concretely, I need to get the option value id of the current order when there is a specific type of option in it. What I use is the following but it's not working and I need help to make it work.
When I run this in phpMyAdmin it gives me the result I'm looking for.
SELECT products_options_values_id
FROM zen_orders_products_attributes
WHERE orders_products_id =27
AND products_options_id =4
Off course the current order is #27. But the following code I use is not working:
Code:
$group_query = $db->Execute("select products_options_values_id from " . zen_orders_products_attributes . " where orders_products_id = '" . $zf_insert_id . "' and products_options_id = '4'").
I'm pretty sure the problem is about getting current order number which is the "order product id" in the table. I don't know much about the variable transfert data syntax so I really need your help please! :(
-
Re: email order confirmation to third party
This speaks to an ongoing ambiguity in all your posts here, where there seems to be an assumption that your customers are always ONLY purchasing ONE product with only ONE attribute selected, because your code does nothing to accommodate different notices to other vendors based on a purchase of multiple items in the cart.
For example, your query above only works if the FIRST option value id is a match, and ignores all other option value ids.
Better to loop through the $class->products array, and for each product in that array, loop through the corresponding $class->products[$i]['attributes'] array to find all the ['values_id'] elements, and compare those against your list of special cases. This is the most accurate data to work from, and is more efficient instead of making a number of new database queries needlessly.
Code:
for ($i=0, $n=sizeof($class->products); $i<$n; $i++) {
if (isset($this->products[$i]['attributes'])) {
for ($j=0, $n2=sizeof($class->products[$i]['attributes']); $j<$n2; $j++) {
switch($class->products[$i]['attributes'][$j]['value_id']) {
//.... all your case statements here ...
} // end switch
} // end for
} // end if
} // end for
-
Re: email order confirmation to third party
In fact, customers can buy many other products as they want but only one member card, which has this attribute (products_options_id = '4'). There's an extra email that needs to be send to the address associated to this attribute's value selected from a drop down list.
So yes, only one item by order will need this email to be send.
I hope my understanding of what you said is good, my english is far than perfect...
-
Re: email order confirmation to third party
That's what works:
Code:
function update(&$class, $eventID, $paramsArray = array()) {
global $db;
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;
$group_query = $db->Execute("select products_options_values_id from zen_orders_products_attributes where orders_products_id ='". intval($zf_insert_id) ."' and products_options_id = '4'");
if (!$group_query->EOF) {
$this->ClubEmailAddress = '';
switch($group_query->fields['products_options_values_id']) {
case '6':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par la ' . STORE_NAME;
break;
case '7':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par la ' . STORE_NAME;
break;
case '8':
$this->ClubEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par la ' . STORE_NAME;
break;
default:
$this->ClubEmailAddress = '';
break;
}
if ($this->ClubEmailAddress != '')
zen_mail('', $this->ClubEmailAddress,
$this->orderEmailSubjectPrefix,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
}
}
-
Re: email order confirmation to third party
Quote:
Originally Posted by
DrByte
valnoren, using Zen Cart v1.3.9x, it's very simple.
You could hard-code lotsa stuff into the orders class, or you could go with a more sophisticated approach using notifiers/observers as I've outlined below:
1. Edit /includes/classes/order.php and change just one line near the very end of the file:
Code:
$this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL');
becomes this:
Code:
$this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL', array($zf_insert_id, $email_order, $extra_info, $html_msg));
2. Create a new file with the following content:
/includes/classes/observers/class.sendGroupOrderNotices.php
Code:
<?php
/**
* observer class to send custom extra order emails to supplier based on customer group membership
*
* @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.sendGroupOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
class sendGroupOrderNotices extends base {
/** constructor method !
*
* Attach observer class to the global $zco_notifier and watch for a single notifier event.
*/
function sendGroupOrderNotices() {
$this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
/**
* Set the specialGroupId to the number of the customer-group assigned in your admin
*/
$this->specialGroupId = 1;
/**
* Set the proper email address for the additional copy of order confirmations to be sent to
*/
$this->specialGroupEmailAddress = 'noreply@mail_domain.com';
/**
* 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'] . "'");
if (!$group_query->EOF && $group_query->fields['customers_group_pricing'] == $this->specialGroupId) {
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
}
}
You can
customize the section in red, as needed.
3. Create a new file with the following content:
/includes/auto_loaders/config.sendGroupOrderNotices.php
Code:
<?php
/**
* autoloader activation point for custom group order email notices
*
* @package initSystem
* @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: config.sendGroupOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
/**
* Autoloader to instantiate observer class
*/
$autoLoadConfig[90][] = array('autoType'=>'class',
'loadFile'=>'observers/class.sendGroupOrderNotices.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'sendGroupOrderNotices',
'objectName'=>'sendGroupOrderNotices');
Can this be done for manufacturer? If customer order some product manufacturer also receive confirmation email. :unsure: