Order - Copy order

  • Posts: 51
  • Thank you received: 6
1 year 10 months ago #342102

-- HikaShop version -- : 4.6.0
-- Joomla version -- : 3.10.9
-- PHP version -- : 7.4.29
-- Browser(s) name and version -- : Firefox

When you copy an order it copies it with the current status, for example 'Closed'.
If copying an order, could it not copy it as you are starting a new order and allocate it the status of 'Created'? You can then start the order journey with the copied order.

Thank you
David

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

  • Posts: 81515
  • Thank you received: 13068
  • MODERATOR
1 year 10 months ago #342107

Hi,

You should be able to do that with a mass action (menu System>Mass actions) with a trigger "after an order is created", with a filter on the order column "order_status" being different than "created" and with an action "update the values" on the order_status column in "string" mode with the value "created".
That way, when an order is created or copied, it will check that the order status is "created" and if not it will set it to "created".

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

  • Posts: 51
  • Thank you received: 6
1 year 10 months ago #342117

Great, thank you.
I have set this up and it is working.
Is there any way to remove the history, as it records a history of a status that has not happened?

Thank you for the quick response.

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

  • Posts: 81515
  • Thank you received: 13068
  • MODERATOR
1 year 10 months ago #342124

The mass action mechanism doesn't allow for history manipulation. However, you could do it with an action "run MySQL query" with a query like this for example:

DELETE FROM #__hikashop_history WHERE history_order_id={order_id};
Just make sure this action is before the one I talked about in my previous message so that the first history record is deleted before the second one is added for the status reset.

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

  • Posts: 51
  • Thank you received: 6
1 year 10 months ago #342154

I will try this out.
From testing the mass action yesterday, a history was not added for the change of status.

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

  • Posts: 51
  • Thank you received: 6
1 year 10 months ago #342159

The code works standalone. For example as an action button for a user to click after they have done a copy or set to run After an Order is Updated (but you would not want this as you would keep losing your history each time you updated).

However, it does not work After an Order Is Created. It is as if the history record has not been written when the trigger fires.

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

  • Posts: 81515
  • Thank you received: 13068
  • MODERATOR
1 year 10 months ago #342160

Ah yes, the history entry is added after.
Then, what you can do is instead a second mass action with a trigger "after an order is updated" with a filter on the order_status column being equal to "created" and with that MySQL query as action.
That way, it will trigger after the order_status is set to "created" and thus it should remove the history of the order creation with the status set to "closed" when it was copied.

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

Time to create page: 0.066 seconds
Powered by Kunena Forum