How to change order status from PHP?

  • Posts: 13
  • Thank you received: 2
  • Hikashop Essential
7 years 8 months ago #264173

Hi,

I have to integrate a bank transfer payment app. It handles all invoicing and payment according to local law, what is not easy other way.
When all finished, it calls a php on my site where I want to change the order status to "confirmed" from php.
I know the order ID, but I did not find and doc what functions can I call to change the status of order.
I need to trigger the user notification email as well.

Thank you for your help!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 8 months ago #264176

Hi,

$order = new stdClass();
$order->order_id = $order_id; // Information needed
$order->order_status = 'confirmed';

$hikashopHelper = rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php';
if(file_exists($hikashopHelper) && include_once($hikashopHelper)) {
    $orderClass = hikashop_get('class.order');
    $orderClass->save($order);
}

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: danidek

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

  • Posts: 13
  • Thank you received: 2
  • Hikashop Essential
7 years 8 months ago #264247

Thank you!. I've added a joomla login script before to get authenticated and it changes the status well. I've used Virtuemart before, but with Hikashop it takes 20 minutes what I did in Virtuemart in 2 days...

Can you help me in the notification of the user as well? The email was not sent.

The following user(s) said Thank You: Jerome

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 8 months ago #264297

Hi,

You can add such line before the save:

$order->history->history_notified = 1;

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
7 years 3 months ago #274735

What about to set the remark beside the status changed message?

Is it $order->history->mymessage ?

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
7 years 3 months ago #274801

We noticed one thg when using $orderClass->save($order);

the invoice number was not generated.....did we miss out something?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 3 months ago #274739

Hello

$order->history->history_data
Don't hesitate to take a look at the HikaShop code and plugins code in order to see how they are dealing with order status modification.
You can find for example a lot of useful code in the HikaShop helper core file ; in the hikashopPaymentPlugin class definition.

The invoice number is only generated by the save function when the status of the order changes from the created order status to one of the invoice order statuses as you can configure in the menu System>Order statuses. So you might actually have an issue with your order statuses, or you didn't set an invoice status in the order_status attribute of your $order object.

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.
Last edit: 7 years 3 months ago by nicolas.

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
7 years 3 months ago #275010

Dear Jerome

We are unable to find "invoice order statuses as you can configure in the menu System>Order statuses" since version 3.1.1 , can you advise?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 3 months ago #275025

Hello,

I'm sorry but I cannot ; There is the "invoice" column in the order statuses listing so I don't understand your message.

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.

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
7 years 2 months ago #276803

Jerome wrote: Hello

$order->history->history_data
Don't hesitate to take a look at the HikaShop code and plugins code in order to see how they are dealing with order status modification.
You can find for example a lot of useful code in the HikaShop helper core file ; in the hikashopPaymentPlugin class definition.

The invoice number is only generated by the save function when the status of the order changes from the created order status to one of the invoice order statuses as you can configure in the menu System>Order statuses. So you might actually have an issue with your order statuses, or you didn't set an invoice status in the order_status attribute of your $order object.

Regards,


we are unable to find as you mentioned since version 3.1

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 2 months ago #276821

Hi,

Kind you provide a screenshot of what you're looking at ?

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

Time to create page: 0.086 seconds
Powered by Kunena Forum