If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / All Other Contributions/Addons / Custom email per product post-purchase

Custom email per product post-purchase

Started by brandon on 10 Oct 2011, 12:02 PM · Views: 1,289

Results 1 to 7 of 7
10 Oct 2011, 12:02 PM
#1
brandon avatar

brandon

New Zenner

Join Date:
Mar 2005
Posts:
64
Plugin Contributions:
0

Post #1 by brandon

I have a client that sells complex products. The cart needs to send, by email (not make available for download), an information packet upon completion of purchase. Look at http://tinyurl.com/4yr9n2l for the production example (side note - we tried using attributes to do the item variations but were not happy with the complexity from the customerś viewpoint).

This packet will differ depending on the item ordered.

I am designing a modification that would parse $this->products to use the (unused at this client's site) model number field to trigger the sending of the email, on the send_order_email function (...classes/order.php) sot that, for instance, if the field for an item contains "PKT20011201", the function would send an email to the customer with PKT20111201.pdf as an attachment. And use a new table to keep track of what order resulted in what packet(s) have been sent.

Anybody have a better way?

10 Oct 2011, 4:13 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

As far as sending the emails, that's the same approach I'd likely take.
Your code would be somewhat more portable if you were to hook the NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL notifier point and write a custom observer class to do all your notifications. That way you're not editing core code files, and your upgrades will be potentially simpler down the road.

.
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.

10 Oct 2011, 6:47 PM
#3
brandon avatar

brandon

New Zenner

Join Date:
Mar 2005
Posts:
64
Plugin Contributions:
0

Post #3 by brandon

TY for the quick response.

DrByte:

Your code would be somewhat more portable if you were to hook the NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL notifier point and write a custom observer class to do all your notifications. That way you're not editing core code files, and your upgrades will be potentially simpler down the road.

I understand and this is yet another reason I wish I had not just dived into hacking mode 6 years ago.

  1. Assuming that 1.4 is dead (I do), does the same hook structure exist in 1.5 and wiil it in 2.x. Since I expect to be using one and/or the other before too many more years are gone, I want to make sure learning the current "hooking" will be an investment. In any case, what is the best current doc/tutorial/example for use of notifier points in zencart?

  2. This particular site is so modified (fortunately, well documented) that it is too late to make upgrading anything but tedious. Also, I already have mods to this class file so I am not shy about making more :)

10 Oct 2011, 7:32 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #4 by drbyte

There are many free addons that use observer/notifier hooks to do everything.
Some documentation here: http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#Observer_Class

Some terms you might search the forum for include:
sendGroupOrderNotices
emailFor404

.
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.

12 Oct 2011, 1:58 PM
#5
brandon avatar

brandon

New Zenner

Join Date:
Mar 2005
Posts:
64
Plugin Contributions:
0

Post #5 by brandon

DrByte:

hook the NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL notifier point

I assume you meant NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL?

This looks very promising. TY for the pointer. One tricky part (seems to me) is getting the auto-load order right.

12 Oct 2011, 4:06 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #6 by drbyte

No, I meant NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL.
But your selection might work fine too.

As for auto-load order, I'm not sure about what you really mean.
You can load your stuff anytime after the normal stuff loads. Start at 200 and adjust if needed (unlikely).

.
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.

12 Oct 2011, 5:39 PM
#7
brandon avatar

brandon

New Zenner

Join Date:
Mar 2005
Posts:
64
Plugin Contributions:
0

Post #7 by brandon

DrByte:

No, I meant NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL.
But your selection might work fine too.

As for auto-load order, I'm not sure about what you really mean.
You can load your stuff anytime after the normal stuff loads. Start at 200 and adjust if needed (unlikely).

Re NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL: I just found the correct notify point in 1.3.9 - I guess it wasn't there in 1.3.7 when the doc was written. My most sincere apologies for doubting you :)

BTW, in an interrupt-rich system, choosing the best point for inserting a custom handler can be an art. Sometimes it boils down to semantics. I suspect both notifies are occurring at almost the same logical point :)

Re autoload order: The tutorial teaches some more precise loading order. I did think that, in my case, it didn't matter - I am happy to load last.