API / Hooks

Has any official documentation or instructions been released for the hooks that are built into 2.0? I need to use them, and I couldn’t find anything.


Thanks Sno!

I read through the documentation, but I am still not sure how exactly to get a hook to work. I need to have some php code run after an order is successfully placed.

Read through these posts, it may help. [url]http://forum.cs-cart.com/showthread.php?t=10273[/url]

You could just add the code to /customer/views/orders/details.tpl file

{if $smarty.request.confirmation == "Y"} {* place any code you wish to display on this page right after the order has been placed *}
{hook name="orders:confirmation"}

If you do want to use hooks then you’ll need create/use the file, customer/addons/ADDON_NAME/hooks/orders/confirmation.post.tpl, but you’ll need to create an complete addon which can be installed.

If I put the code in this area, it is processed when an order is successfully placed. But it is also processed when the refresh button is pressed. Where should I place the code so that it is only processed after a successfully placed order only.

You are probably interested in a few core functions:

fn_order_placement_routines - ln 1865 - /core/fn.cart.php

You can see there is a hook defined there.

Also, take a look at:

fn_change_order_status - ln 832 - /core/fn.cart.php

There is a hook set there as well…

I am using fn_change_order_status hook from a chron job but a error get displayed call to undefined function.that function is defind in a addon ans is calling from the other addon.Can any one help me why i am getting this error