checkout complete event

  • Posts: 252
  • Thank you received: 1
8 years 2 months ago #249515

-- HikaShop version -- : HikaShop Business 2.6.3
-- Joomla version -- : 3.5
-- PHP version -- : 5.5.12

Hi,
I need to write a plugin when user complete the check out and payment process, it will write out the amount to another system. So I put my code in onAfterCheckoutStep, but it seems the plugin method never been called, Did I choose the wrong event? which one should I use?

Best regards
Scott

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 2 months ago #249532

Hi,

You should use the trigger "onAfterOrderCreate".
www.hikashop.com/support/documentation/6...mentation.html#order

The checkout step trigger is related to the custom blocks that you can put in your checkout (like it is done in user points, hikamarket terms & condition, etc).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: twscott

Please Log in or Create an account to join the conversation.

  • Posts: 252
  • Thank you received: 1
8 years 2 months ago #249727

Hi Jerome,
Thanks for the direction, it's very helpful.
I now am dealing with the update order process, so I need to get old order content so I can complete the update of my remote system. Could you show me how to get the old order object?

My 2ed question is, in onAfterOrderDelete($elements), is the "elements" the id of the deleted order or the deleted product ids in the order?
Thanks in advance

Best regards
Scott

Last edit: 8 years 2 months ago by twscott.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 2 months ago #249731

Hi,

The old order object ?
In the onAfterOrderCreate trigger, there is no such object since the order has just been created. The only order object is the one given to the function.
In the onAfterOrderUpdate trigger on the other end, you do have an old order object that you can access in $order->old. Is that what you're talking about ?

In onAfterOrderDelete, $elements is an array of order ids.

The following user(s) said Thank You: twscott

Please Log in or Create an account to join the conversation.

  • Posts: 252
  • Thank you received: 1
8 years 2 months ago #249932

Hi,Nicolas,
Thanks for your answer.
I have done written the plugin for onAfterOrderCreate().
The function is to maintain our remote system for the products stocks and the product quantity in every order.
But when it comes to update and delete order, I found there seem to have some problems, I am not sure if I understand correctly.
In updating, there is no products info in $order->old objects.
in deleting, the onAfterOrderUpdate() was triggered instead of onAfterOrderDelete(),
so my plugin could not get the required informaton from these two events. where else can I find product quantity changing information? or do you have any suggestion for the issue?

Best regards
Scott

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 2 months ago #249933

Hi,

I don't see why onAfterOrderUpdate would be called when you delete an order.
Look at the code of the delete function in administrator/components/com_hikashop/classes/order.php and you'll see that when you delete an order it's the onAfterOrderDelete trigger which is called.
And yes, there is no product information when the order is updated since that information is not necessary usually. It's up to you to load it with a MySQL query on the hikashop_order_product table using the order_id in $order->order_id.
As a quick a dirty way, you could use the loadFullOrder function to load all the order data as presented in our sample codes:
www.hikashop.com/support/documentation/6...umentation.html#code

The following user(s) said Thank You: twscott

Please Log in or Create an account to join the conversation.

  • Posts: 252
  • Thank you received: 1
8 years 2 months ago #250927

Hi nicolas,
I've upgrade to new version and use loadFullOrder function to load the old Order.
but I got a new trouble that I put the following
function onBeforeOrderUpdate(&$order,&$do) {
$orderClass = hikashop_get('class.order');
$this->oldOrder = $orderClass->loadFullOrder($order->order_id, true, false);
}
but in $this->oldOrder it gets the new order data instead of old order.
Is there any wrong with the code or is there any walk around?

Best regards
Scott

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 1 month ago #250951

Hi,

It's not possible that you get the new order data with a loadFullOrder in a onBeforeOrderUpdate trigger. However, it's possible that the order product data has already been updated.
If that's what you're talking about, then it's the trigger onBeforeOrderProductsUpdate(&$order, &$do) that you want to implement instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum