Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Nov 2008
    Posts
    4
    Plugin Contributions
    0

    Default Order confirmation email recipients based on product purchased

    Hi all, I've got sort of a strange situation I need to solve here.
    I have a zen cart 1.3.7.1 store that I will be adding a couple of virtual products to (not downloadable, they're organization memberships), anyway I need to set things up so that when those two products are purchased then an email is sent not only to me but to this other guy. Problem is, he can't receive confirmation emails when any of the other products are sold, just his.

    so basically, I need something like:

    "if product_id_1 is sold, then email me and john doe"

    otherwise, for all other products, just email me.

    Does that make sense? I can't seem to find any posts or mods relating to something of this nature. I'm fairly proficient with php, with a little bit of help I could probably custom code this if need be, but I'm not sure where to start.
    Any help would be greatly appreciated.

    Thanks,
    Michael Smith

  2. #2
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Order confirmation email recipients based on product purchased

    You'll need to customize the function send_order_email in the file includes/classes/order.php - note that there is no override capability for this file.

    Basically you'll want to do a conditional test to see if your target product is in the array $this->products, and if it is, send an extra email
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  3. #3
    Join Date
    Nov 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Order confirmation email recipients based on product purchased

    Bunyip,

    Ok cool..I'll go check that out now and see what I can do with it. I appreciate your response. I may have another question or two as well. We'll see how my attempt at hard code customizing goes. hehe

    I see you're in my neck of the woods. I'm in Denver myself.

    Thanks again,
    Michael

  4. #4
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Order confirmation email recipients based on product purchased

    If you're reasonably proficient with php you shouldn't have any great problems.

    I'm not too far away from you - in Conifer.
    If you need any direct assistance, PM me for phone/email details.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  5. #5
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Order confirmation email recipients based on product purchased

    I was just giving this a little more thought, and it should be possible to achieve what you want without actually modifying the core class file order.php

    You could use the notifier system, attaching a function to the notifier NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL that is set during the checkout process. That way you would only be adding new files and not editing a core file. It's a bit more complicated though.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  6. #6
    Join Date
    Nov 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Order confirmation email recipients based on product purchased

    Ok, yeah, I've poked around in that file. I never would have found that on my own. I'm not worried about editing the core file...I've been running this store for about 3 years now, made several modifications and have plenty of backups.
    I'll just have to play around with things. I'm not going to mess with it until tomorrow, I'll post updates here for you or anyone else who might be interested.

    Thanks again,
    Michael

  7. #7
    Join Date
    Nov 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Order confirmation email recipients based on product purchased

    Ok, I think I'm on the right track. I found function_send_order_email at line 863. so starting at line 865 I've added:

    PHP Code:
    if (in_array("Post 1 New Membership",$this->products)) {

        } else {


    Where Post 1 New Membership is 'name' of product, and it's looking in the $this->products (line 188) array for this info.

    Now, I'm a little confused by all the email functions below all of this. I'm not sure if there is something preexisting I can call or if I need to write a new function. I'm kind of thinking I can basically call zen_mail $html_msg I guess to a new variable I create that holds the Post 1 Commander's email address. He's the guy that needs to get an email when his new membership is purchased.

    I could use a little help figuring out if I can use a pre-existing email function or what exactly to do next. What do you think?

    Thanks a bunch,
    Michael

  8. #8
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Order confirmation email recipients based on product purchased

    You should be able to use an existing email function - just copy the one that sends the additional email already, and modify the recipient and content.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  9. #9
    Join Date
    Apr 2006
    Posts
    15
    Plugin Contributions
    0

    Default Re: Order confirmation email recipients based on product purchased

    Ok, well I got it working in a testing environment but honestly, it is NOT the way to go for this sort of thing. Basically I checked if product_id's were in the products array and if so then zen_mail to a variable that stores the additional email address to send to. I copied the SEND_EXTRA_ORDER_EMAILS_TO function, chopped it up and rewrote large bits of it to do what I needed. Again though, it's not really a great solution because I'll need to add email addresses in the future for other products for other posts.

    So, I've been looking at the notifier in includes/modules/checkout_process.php. I'm thinking that the way to go with this would be to create a full fledged add-on that can be controlled from the admin. What I need is this:

    A form on the admin side that will let me specify a product(s) that triggers an email to a specified email address. Basically we have other Posts that want to have their new memberships and renewal on our storefront, when someone signs up (buys one of those products) then the Commander of the Post who's membership was purchased will receive an email. This is in addition to the emails that get send by the admin system anyway. So, if product 1 is purchased then bob jones in Denver gets an email. if product 2 is purchased then john doe in Colorado Springs gets an email, but bob jones doesn't.
    Does all that make sense?

    So, my question here is, where would I start in writing an add-on and is there any big pitfalls I should keep in mind while doing this?
    And where would I start with the notifier system, I feel like I'm missing something with the notifier system, I see where it auto loads in config.core but I don't see any kind of constructor for it. I don't really understand what controls it's behavior.

    I've never taken my Zen Cart knowledge this far, it's mostly been templates, custom forms and such on the front end. I'm also a bit weak on the OOP side of things, so it takes me a while to see what's probably painfully obvious to everyone else.

    Any and all thoughts are greatly appreciated. I know it sounds like a heck of a mess to figure out but I need to come up with something.

    Thanks,
    Michael

    p.s. just realized I logged in under my other account. this is LegionSmith

  10. #10
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Order confirmation email recipients based on product purchased

    Start with the wiki (link at top of page) for tutorial on the notifier class. First thing to do would be to add a new field to the product table (or for future upgradeability, into a new product_extra table cross-referenced by product id) so you can identify who gets the extra email for the product.
    That would make it easier to just zip through the ordered products post-checkout and send an email if there's an address in that new field for the product.
    Last edited by bunyip; 9 Feb 2009 at 05:55 AM. Reason: grammar fix
    Neville
    An assumption is what you arrive at when you get tired of thinking...

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Admin order confirmation email based on shipping cost
    By jmsnyder23 in forum Managing Customers and Orders
    Replies: 9
    Last Post: 2 Jan 2015, 02:35 AM
  2. Send additional order confirmation email based on product ordered.
    By abcschooldr in forum General Questions
    Replies: 8
    Last Post: 20 Mar 2012, 09:35 PM
  3. Sort email recipients by products purchased?
    By len7560 in forum General Questions
    Replies: 2
    Last Post: 9 May 2008, 12:23 PM
  4. Customize order receipt based on product purchased
    By murphysr in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 13 Aug 2007, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg