Zen Cart Logo
Forums / All Other Contributions/Addons / Execute API on successful order

Execute API on successful order

Views: 2,411

Results 1 to 20 of 22
14 Jul 2012, 12:35 PM
#1
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Execute API on successful order

Hi,

I am using version 1.3.9h.

I am trying to integrate an API which uses CURL and having a URL based submission of SMS to customer mobile number on successful order creation.

I need help regarding where to insert this code in zencart?

I can provide the API snippet if required.

Thanks & Regards,

14 Jul 2012, 2:35 PM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Execute API on successful order

includes/classes/order.php is where you'll need to do the work. down at the bottom you'll find 'function send_order_email' which might be one place you could bundle it in.

14 Jul 2012, 4:27 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,701
Plugin Contributions:
56

Re: Execute API on successful order

If you look at "SMS on Sale," you'll see how to do it without changing core Zen Cart files.

http://www.zen-cart.com/downloads.php?do=file&id=291

16 Jul 2012, 11:58 AM
#4
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

Hi,

Thanks all for your reply.

@swguy:
That addon uses email link for SMS trigerring which is not a case for my service provider. My service provider has provided a URL link which triggers SMS. Any way that can be modified? It would be great ifyour addon support this type of API calls as it is very common here in INDIA. Mostly service providers are providing URL API call instead of email-to-SMS link.

@niccol:
I will try to update this file and will update you with the result.

16 Jul 2012, 12:04 PM
#5
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Execute API on successful order

swguys approach is better. He said to look at it to learn how to structure the code so that you do not have to edit core files. You should do that. You just need to edit the observer class so that it does what you wish rather than what his version does.

16 Jul 2012, 12:21 PM
#6
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

niccol:

swguys approach is better. He said to look at it to learn how to structure the code so that you do not have to edit core files. You should do that. You just need to edit the observer class so that it does what you wish rather than what his version does.

Thanks a lot. I will definitely try to do this and update you.

25 Jul 2012, 10:25 AM
#7
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

HI,

How to add order number in SMS? I mean which variable will return the order ID value for SMS.

Thanks & Regards,

25 Jul 2012, 10:26 AM
#8
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

swguy:

If you look at "SMS on Sale," you'll see how to do it without changing core Zen Cart files.

http://www.zen-cart.com/downloads.php?do=file&id=291

HI,

How to add order number in SMS? I mean which variable will return the order ID value for SMS.

Thanks & Regards,

25 Jul 2012, 10:48 AM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,701
Plugin Contributions:
56

Re: Execute API on successful order

If you switch to using NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL, then $zf_insert_id (the order id) is one of the parameters.
In ./includes/classes/observers/class.msg_owner.php, change

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

to

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

then change

function update(&$callingClass, $eventID) {

to

function update(&$callingClass, $eventID, $paramsArray = array()) {
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;

and you have the order id in $zf_insert_id.

25 Jul 2012, 11:00 AM
#10
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

swguy:

If you switch to using NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL, then $zf_insert_id (the order id) is one of the parameters.
In ./includes/classes/observers/class.msg_owner.php, change

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

to

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

then change

function update(&$callingClass, $eventID) {

to

function update(&$callingClass, $eventID, $paramsArray = array()) {
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;

and you have the order id in $zf_insert_id.

Hi,

Thanks a lot. Thanks a lot for your HELP.

It worked for me like a charm...

You are genius..

I am using your Module with CURL API from my SMS provider for sending sms to customer on successful order.

But I am facing problem that on checkout confirmation, SMS is generated but checkout_success.php shows a blank page.

So, how can I get my website working?

CURL Code which I am using:

<?php
$ch = curl_init();
$user="user_id:password";
$receipientno="900XXXXXX";
$senderID="TEST SMS";
$msgtxt="this is test message , test";
curl_setopt($ch,CURLOPT_URL,  "http://api.xxxxxxxx.com/xxwwxx/MessageCompose");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=$user&senderID=$senderID&receipientno=$receipientno&msgtxt=$msgtxt&state=0");
$buffer = curl_exec($ch);
if(empty ($buffer))
{ echo " buffer is empty "; }
else
{ echo $buffer; }
curl_close($ch);
?>
 

Thanks in Advance.

25 Jul 2012, 11:05 AM
#11
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,701
Plugin Contributions:
56

Re: Execute API on successful order

If you're getting a blank page, you need to follow the blank page debugging steps:

http://www.zen-cart.com/content.php?124

25 Jul 2012, 12:34 PM
#12
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

swguy:

If you're getting a blank page, you need to follow the blank page debugging steps:

http://www.zen-cart.com/content.php?124

Hi,

i have already tried these steps but no luck.

I think there might be a cURL API causing error. And I dont have any idea about cURL.

It would be great if you can help me with this.

I have already provided code which I am using.

Thanks.

25 Jul 2012, 6:14 PM
#15
drbyte avatar

drbyte

Sensei

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

Re: Execute API on successful order

Might be helpful to have a zip containing all the code affected by this.

26 Jul 2012, 4:46 AM
#16
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

DrByte:

Might be helpful to have a zip containing all the code affected by this.

Hi,

Please find attached zip file of file affected.

I have used SMS ON SALE addon and modified a bit to use with cURL API provided by my service provider.

Thanks & Regards,

[Attachment no longer available]

25 Sep 2012, 5:10 AM
#17
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

swguy:

If you switch to using NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL, then $zf_insert_id (the order id) is one of the parameters.
In ./includes/classes/observers/class.msg_owner.php, change

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

to

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

then change

function update(&$callingClass, $eventID) {

to

function update(&$callingClass, $eventID, $paramsArray = array()) {
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;

and you have the order id in $zf_insert_id.

Dear swguy,

What to do when I update order status from Zen-cart Admin Panel (e.g. Shipped) and want to execute this same Module to send SMS?

Thanks.

25 Sep 2012, 9:46 AM
#18
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,701
Plugin Contributions:
56

Re: Execute API on successful order

The notifiers don't fire in admin. You'd need to just call the underlying logic yourself.

25 Sep 2012, 11:03 AM
#19
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

swguy:

The notifiers don't fire in admin. You'd need to just call the underlying logic yourself.

Ok. So If I update a Order status from Zen Admin Panel, order.php is file which changes/updates status in database?

Any pointers/directive that I can look for? Where to Apply that cURL Logic?

What basically I wanted to do is, use your SMS Add-on for sending even of Order Status change.

Thanks.

5 Oct 2012, 12:22 PM
#20
max4u avatar

max4u

New Zenner

Join Date:
Jul 2012
Posts:
15
Plugin Contributions:
0

Re: Execute API on successful order

max4u:

Ok. So If I update a Order status from Zen Admin Panel, order.php is file which changes/updates status in database?

Any pointers/directive that I can look for? Where to Apply that cURL Logic?

What basically I wanted to do is, use your SMS Add-on for sending even of Order Status change.

Thanks.

Any updates?