Question

Goodmorning Stacks,

Since a couple of days we've been working on a dropshipping-service inside an existing webshop (opencart 1.5.6). I already prepared my SOAP-request (dropshipping) for use inside the store, the only thing I'm not sure about is the location of the desired method. Since you've need to complete the payment before you can confirm the order it seems we need to adjust the

catalog/controller/checkout/confirm.php

However when I look up the code of this file I can't find any clue where to place the method. Inside the catalog/model/checkout/order.php we can find the addOrder() method, looks like this is a temp order till you've succesfully completed your payment and pressed the confirm button.

Can anybody tell me about the way Opencart handles the orders and how-to adjust the code the proper way at the right location?

Was it helpful?

Solution

Having just done this myself, whilst I'm aware this question is from a while ago I thought it would be helpful to post my approach.

The method I have used is to execute a function in a separate file, and call this from catalog/controller/checkout/success.php

There are two methods to do this, either via directly updating the file or by using vQmod. I'm not going to go into much detail on vQmod here as it is covered extensively elsewhere (https://code.google.com/p/vqmod/). The latter is my preference as it requires no modification of the original file, however I will be covering both.

1) To modify the file directly, simply open it and on line 7 you will see

if (isset($this->session->data['order_id'])) {

immediately after this line you can add your hook. I used something like

include("catalog/controller/checkout/dropship_order.php");
sendOrderToDropship($this->session->data);

2) Alternatively, use the following vQmod code to perform the same action on the fly

<file name="catalog/controller/checkout/success.php" error="log">
    <operation error="skip">
    <search position="after"><![CDATA[if (isset($this->session->data['order_id'])) {]]></search>
    <add><![CDATA[
            include("catalog/controller/checkout/dropship_order.php");
            sendOrderToDropship($this->session->data);
    ]]></add>
    </operation>
</file>

Both of these methods will result in the calling of your sendOrderToDropship function when the success page is loaded; and inside that function you can perform whatever action you require. By sending in the data array, you also gain access to the order information (critically the order id) so you can perform any processing required.

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top