Are you saying I can still use the $email_order variable in this file to send the same email? Or do I have to call the $order var before it?
Are you saying I can still use the $email_order variable in this file to send the same email? Or do I have to call the $order var before it?
Here is the current code I have tried to get working. But I cant seem to figure out how to make it work.
This is all I get when the email is sent.PHP Code:
protected function processProducts($products)
{
foreach ($products as $product) {
switch ($product['id']) {
case '1':
$this->emailOrder();
break;
case '2':
break;
}
}
}
public function emailOrder($zf_insert_id = null)
{
if ($zf_insert_id === null) $zf_insert_id = $this->orderId;
$extra_info = email_collect_extra_info('', '', $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], $this->customer['telephone']);
$html_msg['EXTRA_INFO'] = $extra_info['HTML'];
// Add extra heading stuff via observer class
$this->extra_header_text = '';
$this->notify('NOTIFY_ORDER_INVOICE_CONTENT_FOR_ADDITIONAL_EMAILS', $zf_insert_id, $email_order, $html_msg);
$email_order = $this->extra_header_text . $email_order;
$html_msg['EMAIL_TEXT_HEADER'] = nl2br($this->extra_header_text) . $html_msg['EMAIL_TEXT_HEADER'];
zen_mail(
'',
'the email',
SEND_EXTRA_NEW_ORDERS_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'],
STORE_NAME,
EMAIL_FROM,
$html_msg,
'checkout_extra',
$this->attachArray,
$this->customer['firstname'] . ' ' . $this->customer['lastname'],
$this->customer['email_address']
);
}
Office Use Only:
From:
Mail:
IP Address: x.x.x.x - x.x.x.x
Host Address: my host
Date and Time: Fri Jan 8 2021 10:27:42 PST
I guess you could change both of these:
toCode:$this->processProducts($order->products);
As for generating the email content, in your copy/pasting you've missed at least a couple important variables such as $email_order and $email_html which are the text-only and html-version of the email message being assembled.Code:$this->processProducts($order);
Perhaps simplify things a lot with:
PHP Code:
protected function processProducts($order)
{
foreach ($order->products as $product) {
switch ($product['id']) {
case '1':
$this->send_emails($order);
break;
case '2':
break;
}
}
}
protected function send_emails($order)
{
$text_msg = '';
$html_msg = [];
$text_msg .= 'Order Number: ' . $this->order_id . "\n";
$text_msg .= $order->customer['firstname'] . ' ' . $order->customer['lastname'] . "\n";
$text_msg .= $order->customer['email_address'] . "\n";
$text_msg .= $order->customer['telephone'] . "\n";
zen_mail(
'custom-recipient-name',
'custom-recipient-email',
EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $this->order_id,
$text_msg,
STORE_NAME,
EMAIL_FROM,
$html_msg,
'checkout_extra'
);
}
.
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.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Ya, that's because I didn't follow my gut and go check the actual order class code:
https://github.com/zencart/zencart/b....php#L113-L133
The customer name is not split into first/last names when the order is saved.
You can get it with $order->customer['name'].
.
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.
No, DrByte, I think your first inclination was correct, because $order->create($orders_id) isn't called in this sequence to cause that "redefinition". The call to the definition of $order in includes/modules/checkout_process.php doesn't include the $order_id which means that the cart method is called, no? There $this->customer does have firstname and lastname.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
The way my proposed observer class instantiates its own new instance of the order class and queries the order details directly, means it is hydrating the order afresh. This lets this code also work out-of-band in case one wants to use the same logic elsewhere. (Or bring other out-of-band logic into a function like this.)
.
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.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
I have been trying to pull the product id inside of the order.php file here is what I have so far but it does not seem to work.
I have also tried this.PHP Code:
if ($this->products['id'] == 1) {
// do something
}
PHP Code:
foreach($this->products as $product) {
switch ($product['id']) {
case 1:
// do something
break;
case 2:
// do something
break;
}
}
Bookmarks