Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencart event for checkout success

Tags:

opencart

How to handle custom after purchase action in opencart, without modifying core code?

Event 'post.order.add' is called before payment and I can't find anything for after the payment had been completed :( the most important action missing

like image 806
John Magnolia Avatar asked Nov 17 '25 08:11

John Magnolia


1 Answers

I can think of two ways:

1) You could use event post.order.history and then check number of history rows to determine whether to apply action or not. If there is only one that would indicate the order has only just been confirmed. Something like this:

$this->load->model('account/order');
if (count($this->model_account_order->getOrderHistories($order_id)) <= 1) {
    // do stuff
}

There are probably other flags you could use to decide whether or not to trigger the action - the point being that you just need a condition you can depend on since this action is triggered on payment confirmation and every other order history update thereafter.

2) Use vQmod and apply something to the success.php controller. Install vQmod and construct an xml file like this:

<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <id>Order Success Event</id>
    <version>1.0</version>
    <vqmver>2.4</vqmver>
    <author>[email protected]</author>

    <file name="catalog/controller/checkout/success.php">
        <operation>
            <search position="after"><![CDATA[public function index()]]></search>
            <add><![CDATA[
        // Things to do after order success event
            ]]></add>
        </operation>
    </file>
</modification>
like image 154
Eaten by a Grue Avatar answered Nov 19 '25 03:11

Eaten by a Grue