Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Checkout order update hook  (Read 6539 times)

Offline renato.aloi

  • Newbie
  • *
  • Posts: 11
  • Karma: +4/-0
    • View Profile
Checkout order update hook
« 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

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Checkout order update hook
« Reply #1 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(){

}

“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline renato.aloi

  • Newbie
  • *
  • Posts: 11
  • Karma: +4/-0
    • View Profile
Re: Checkout order update hook
« Reply #2 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!

 

Powered by SMFPacks Social Login Mod