Yup. @mc12345678 is right.
Yup. @mc12345678 is right.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
Currently, we have everything working including sending the emails per product ordered. But what we need to get working is to have the case test send all info through one email instead of multiple.
Such as:
Instead of :Code:Email 1 products 1 products 2
andCode:Email 1 products 1
being sent in different emails.Code:Email 2 products 2
Last edited by Famine_1; 24 Jan 2021 at 01:28 AM.
Wouldn't it be easier to vreate a set of email rules and based upon those rules, forward the copy of the admin email to the appropriate supplier?
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
This is the code I have so far and it sends the email but it sends two if two products are bought at the same time, so I just need it to send all in one email.
There has to be a way to wait for the other products to be tested for right?
PHP Code:
protected function processProducts($order, $order_id)
{
foreach ($order->products as $product) {
switch ($product['id']) {
case '1':
$this->emailOrder($order, $order_id, $product);
break;
case '2':
$this->emailOrder($order, $order_id, $product);
break;
}
}
}
public function emailOrder($order, $order_id, $product)
{
$html_msg = [];
if (!empty($product['attributes'])) {
foreach ($product['attributes'] as $attribute) {
}
}
$email =
// Customer Info
"Customer Name - " . $order->customer['name'] .
"\n\n" .
"Customer Email - " . $order->customer['email_address'] .
"\n\n" .
"Customer Phone - " . $order->customer['telephone'] .
"\n\n" .
// Customer Address
"Customer Address" .
"\n" .
EMAIL_SEPARATOR .
"\n" .
$order->customer['street_address'] .
"\n" .
$order->customer['city'] .
"\n" .
$order->customer['state'] .
"\n" .
$order->customer['postcode'] .
"\n\n" .
// Products Section
"Products Purchased" .
"\n" .
EMAIL_SEPARATOR .
"\n" .
$product['qty'] . "x" . " " .
$product['name'] . "\n" .
// Attributes
$attribute['value'] .
"\n" . EMAIL_SEPARATOR . "\n" .
"Price - " . number_format($product['final_price'], 2);
zen_mail(
'Template',
'[email protected]',
'Product Order' . EMAIL_ORDER_NUMBER_SUBJECT . $order_id,
$email_luigis,
STORE_NAME,
EMAIL_FROM,
$html_msg,
'checkout',
$this->attachArray
);
}
Last edited by Famine_1; 25 Jan 2021 at 05:30 PM.
In processProducts(), perhaps instead of calling emailOrder for each product (which is why it's sending separate emails), you could call a different function which prepares the content of all the separate emails that need to be sent (probably by moving some/most of your current emailOrder code there, and stuffing results into an array of recipients and the generated email output), and then after the foreach in processProducts is completed, call emailOrder which would loop through the array of recipients and send all the order data prepared for each of them.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
based on your code above, you could do something like:
untested. but hopefully it gives you a bit of an idea.PHP Code:
protected function processProducts($order, $order_id)
{
$sendEmail = false;
$products = [];
foreach ($order->products as $product) {
switch ($product['id']) {
case '1':
case '2':
$sendEmail = true;
$products[] = $product;
break;
}
}
if ($sendEmail) {
$this->emailOrder($order, $order_id, $products);
}
}
public function emailOrder($order, $order_id, $products)
{
$html_msg = [];
$email =
// Customer Info
"Customer Name - " . $order->customer['name'] .
"\n\n" .
"Customer Email - " . $order->customer['email_address'] .
"\n\n" .
"Customer Phone - " . $order->customer['telephone'] .
"\n\n" .
// Customer Address
"Customer Address" .
"\n" .
EMAIL_SEPARATOR .
"\n" .
$order->customer['street_address'] .
"\n" .
$order->customer['city'] .
"\n" .
$order->customer['state'] .
"\n" .
$order->customer['postcode'] .
"\n\n" .
// Products Section
"Products Purchased" .
"\n" .
EMAIL_SEPARATOR .
"\n";
$product_email = '';
foreach ($products as $product) {
$product_email .=
$product['qty'] . "x" . " " .
$product['name'] . "\n";
if (!empty($product['attributes'])) {
foreach ($product['attributes'] as $attribute) {
$product_email .= $attribute['value'] .
"\n" . EMAIL_SEPARATOR . "\n";
}
}
$product_email .= "Price - " . number_format($product['final_price'], 2);
}
$email .= $product_email;
zen_mail(
'Template',
'[email protected]',
'Product Order' . EMAIL_ORDER_NUMBER_SUBJECT . $order_id,
$email_luigis,
STORE_NAME,
EMAIL_FROM,
$html_msg,
'checkout',
$this->attachArray
);
}
best.
Thank you! This worked, I got the first stuff but could not figure out the showing of the products.
I am having trouble pulling the comments though.. I have tried:
But it does not work..PHP Code:
$order->info['comments']
Bookmarks