Results 1 to 9 of 9
  1. #1
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Custom function upon successful order placement

    I'm integrating Zen Cart into my own CMS and I have a need to call a custom function when an order is successfully placed. The basic Idea is I'm selling "points" that can then be redeemed for merchandise.

    When an order for points is placed, I want to call a custom function that inserts the number of points purchased into another database table.

    My question is, which particular file should I be working with to place my function call? Zen Cart is new to me and I'm still struggling to find my way around in the code.

  2. #2
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Custom function upon successful order placement

    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  3. #3
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Custom function upon successful order placement

    Thanks yellow1912, that's exactly the kind of information I was looking for!

  4. #4
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Custom function upon successful order placement

    I've been reading through the documentation for the API and testing a little observer class I made. I've also read through some forum posts, but I can't find the nugget of truth I'm looking for yet. The API examples hook into $_SESSION['cart'] and I want to hook into the checkout process. I'm assuming I need to use the NOTIFY_HEADER_END_CHECKOUT_SUCCESS event in my case.

    What object do I attach to in my constructor function? I read some posts about using $zco_notifier, so I've tested a line like:

    $zco_notifier->attach($this, array('NOTIFY_HEADER_END_CHECKOUT_SUCCESS'));

    but nothing in my update() function seems to be getting triggered. In my update function I set up a query to $db to insert some data. Earlier, this worked when I hooked into $_SESSION['cart'] as a sanity check, but nothing happens when attempting to hook into $zc_notifier for the checkout success event. I also tried $this-attach which didn't work either.

    I know I'm close, I just can't figure out how to structure my attach statement. Thanks in advance for any advice.

  5. #5
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Custom function upon successful order placement

    Bump...

    Any ideas at all on this? I can't find any examples of how to hook a function into a successful checkout process. Perhaps I'm just not looking in the right place yet... :-(
    Last edited by Gwixel; 17 May 2008 at 01:20 AM.

  6. #6
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,511
    Plugin Contributions
    126

    Default Re: Custom function upon successful order placement

    Look for SMS on Sale in the downloads area. This shows how to do what you're looking to do; you might want to put it earlier or later in the process, but at least you can get some ideas from looking at this.

    Good luck,
    Scott
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  7. #7
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Custom function upon successful order placement

    Thanks swguy. I think I may be onto something.... I've successfully attached a notifier using: $zco_notifier->attach($this, array('NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION'));

    It's not in the right place yet or doing what I want, but it's a start. I'll post another question if I get stumped...

  8. #8
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Custom function upon successful order placement

    OK, I guess I'm stumped... Looking at SMS on Sale was very helpful. What I need to do is get some info about the products purchased, parse that data and then use it to populate a table in another database. The first thing to figure out is how to get at the array (I'm assuming it's an array) of products purchased in the order. I've been searching the code for something resembling $order->info['products']... Is that where I should be looking, or is that info stored elsewhere?

  9. #9
    Join Date
    May 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Custom function upon successful order placement

    Aha! I found it... The info I needed is found in $order->products['qty'] and $order->products['model'].

 

 

Similar Threads

  1. v151 Global sale function (Change the order of sale/save placement)
    By Trademagic in forum General Questions
    Replies: 2
    Last Post: 19 Dec 2013, 08:55 AM
  2. v151 custom script/function to commit order details to database?
    By filfish in forum General Questions
    Replies: 4
    Last Post: 6 Aug 2013, 08:14 PM
  3. Javascript window.onload=function placement
    By usr50 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 11 Apr 2011, 10:53 PM
  4. Custom invoices payable upon reciept
    By BALCO in forum Managing Customers and Orders
    Replies: 5
    Last Post: 26 Jan 2010, 12:43 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