AbanteCart Community

AbanteCart Development => Development Help Needed => Topic started by: renato.aloi on March 30, 2017, 04:58:11 PM

Title: Checkout order update hook
Post by: renato.aloi on March 30, 2017, 04:58:11 PM
Hi there!

I am developing a payment extension and at the end of payroll process I want to update the order status.

I was calling update function from Checkout order model, but I noticed a strange rule is in place:

$order_query = $this->db->query("SELECT *
                               FROM `" . $this->db->table("orders") . "` o
                               LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)
                               WHERE o.order_id = '" . (int)$order_id . "' AND o.order_status_id > '0'");

if ($order_query->num_rows){ ...

Why is that? Why can I only update order statuses greater than '0'?

So I decided to Hook up the function adding the following code to my core extension php:

public function onModelCheckoutOrder_update()
   {
      // ...
   }

But the hook is not triggering! Any ideas?

Thank you!

Best Regards,
Renato
Title: Re: Checkout order update hook
Post by: abolabo on March 31, 2017, 02:49:52 AM
until order confirmed it have order_status_id=0 (incomplete order). When you click confirm button on checkout/confirm page you should call confirm method of model_checkout_order object. It will set some order status, for example "processing". Then  when payment transaction is complete you should to update order status to complete, failed etc.

See extensions/default_pp_pro/storefront/controller/responses/extension/default_pp_pro.php as example or try to find usage $this->model_checkout_order->confirm().

Also you can hook to model via
public function beforeModelCheckoutOder_confirm(){

}

Title: Re: Checkout order update hook
Post by: renato.aloi on March 31, 2017, 09:03:28 AM
Hi!

My bad! Now I see! I am using default_pp_pro as guideline for my development, but I missed the confirm function call right after ACK==Success!

It is crystal clear for me now! Thank you!