How can I "do something" after a successful PPE order?
This may not be the best place to ask this, but I'll try here first.
When an order is placed and it is successful, the order is taken from Pending to Processing automagically whether or not I'm logged in to see it (if a tree falls in the for forest...)
How can I get I add to the functionality at that stage?
Basically I want to trigger some other code at that point in time. So when a successful order comes in, do "this". How do I hook into that event, so to speak?
Clues?
Re: How can I "do something" after a successful PPE order?
I'm thinking it has something to do with $zco_notifier->notify('NOTIFY_, but which one?
I'm digging now, so really this is just a "if you happen to know, tell me" kind of Q :)
Re: How can I "do something" after a successful PPE order?
At what point in the overall checkout process do you want to do something, what is the something you want to do (more importantly what data at or after that point do you need. Also for what version(s) of ZC are you developing for?
Re: How can I "do something" after a successful PPE order?
Hi MC. Thanks for the reply.
The point I'm after is "success"... the point where the order is considered complete and paid for.
The something I want to do is automatically send the shipping details to the shipping service API. Data I need are the order details (specifically: delivery address, phone number, model and quantities of cart items, shipping service, amount paid for shipping, currency used, order number. I think that's it)
ZC 1.5.4
Re: How can I "do something" after a successful PPE order?
So here's what I've done so far:
/includes/auto_loaders/config.myProcessor.php
Code:
<?php
$autoLoadConfig[10][] = array('autoType'=>'class',
'loadFile'=> 'observers/class.myProcessor.php');
$autoLoadConfig[180][] = array('autoType'=>'classInstantiate',
'className'=>'myProcessor',
'objectName'=>'myProcessor');
?>
/includes/classes/observers/class.myProcessor.php
Code:
<?php
class myProcessorextends base {
function __construct() {
$this->attach($this, array('NOTIFY_CHECKOUT_PROCESS_HANDLE_AFFILIATES'));
}
function update(&$class, $eventID, $paramsArray = array())
{
if ($eventID == 'NOTIFY_CHECKOUT_PROCESS_HANDLE_AFFILIATES')
{
//DO SOMETHING
}
}
}
It seems to be working. What I'm not sure on is if "NOTIFY_CHECKOUT_PROCESS_HANDLE_AFFILIATES" is appropriate (I used it because it appeared to be around the right place in the code for tapping in) and I'm especially unsure on the values I used for autloading (10 and 180). I went with 10 because the wiki used that for its example and I used 180 because PayPal uses up to 170 in paypal_ipn.core.php but really I don't understand it enough to say that was an informed guess.
Re: How can I "do something" after a successful PPE order?
as far as the "do something", that would be a SOAP exchange with the shipper's service as per their API and, upon receiving success, updating the order in the DP from 'processing' to 'shipped' and sending out an email. My next step is to make a cron-job that periodically poles the shipper's servers for tracking numbers (they aren't immediately available) and sending them to the customer when it is available. I'll either need a new DB table for that, or (perhaps simpler) add a status in between "processing" and "shipped".
I hope to eventually also cron up a summary / audit system so the admin can be notified with info such as amount customer paid for shipping vs. amount we were ultimately charged (that too isn't known right away)
Fun stuff.
Re: How can I "do something" after a successful PPE order?
Quote:
Originally Posted by
s_mack
The point I'm after is "success"... the point where the order is considered complete and paid for.
NOTIFY_HEADER_START_CHECKOUT_SUCCESS
... is one suitable hook. I know there are others.
This is the one I use in the ec_analytics module to trigger/send the transaction details of a sale to the Google servers, which is pretty much a similar thing to what you are wanting to do.
Cheers
Rod
Re: How can I "do something" after a successful PPE order?
Ahh, I think I saw that but when I read "Start Checkout Success" I mistook as meaning the checkout process started successfully (ie. right after they click "checkout" in their cart). Thanks.
Re: How can I "do something" after a successful PPE order?
I was also possibly going to suggest: NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL as a possibility, though it is "further" down the line in order processing.
As for the trigger points of 10 and 180... There's a bit of various direction... In some cases it appears that it should be something like 0 and 199+, but then in ZC 1.5.3 there is a new auto load observer that loads at 175, and then there is the suggestion that none should be less than 199 without good reason (which means need to know and understand when to use which)... Don't see a problem with what has been used per se. And for the most part as long as it works. :)
Re: How can I "do something" after a successful PPE order?
Quote:
Originally Posted by
RodG
NOTIFY_HEADER_START_CHECKOUT_SUCCESS
... is one suitable hook. I know there are others.
This is the one I use in the ec_analytics module to trigger/send the transaction details of a sale to the Google servers, which is pretty much a similar thing to what you are wanting to do.
Cheers
Rod
I'd lean more towards a notifier within the checkout_process path. The checkout_success page can be refreshed, resulting in your processing being re-run.