Apply 'Enter user address' function to already imported orders?

  • Posts: 2
  • Thank you received: 0
  • Hikashop Business
1 day 3 hours ago #367838

-- HikaShop version -- : 6.0.0
-- Joomla version -- : 5.3.2
-- PHP version -- : 8.2.28

Hello,

I have imported several orders via CSV, and each one is correctly assigned a user_id. The user is properly linked in the backend, but the address data is not filled in.

When assigning a user manually to an order in the backend, a popup appears with the switch "Enter user address", which fills in the user's address fields in the order.

Is there a way to apply this action in bulk or automatically to existing orders? That is, to have the user's address data applied to orders that already exist, as if the switch had been activated manually.

Thanks for your help.

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

  • Posts: 84079
  • Thank you received: 13634
  • MODERATOR
23 hours 44 minutes ago #367846

Hi,

There is no ready made tool for this.
However, it should be fairly easy to configure a mass action (menu System>Mass actions) to do that:
www.hikashop.com/support/documentation/167-massaction-form.html
You'll want to :
- use the "order" data
- use a filter on "order_billing_address_id" being equal to 0
- use an action "run MySQL query" with the query:

UPDATE #__hikashop_order AS o LEFT JOIN #__hikashop_address AS a ON a.user_id = o.order_user_id AND a.address_type='billing' SET o.order_billing_address_id = a.address_id WHERE o.order_id = {order_id};
When you run that mass action, it will process all the orders (the first 500 if you leave the "limitation" value to 500. You can potentially increase that value to a few thousands, but more than that and the PHP process will likely crash in the middle. However, you can just process the mass action several times until all the orders are processed) and set the billing address of these orders to be one of the billing addresses of the user.
Then, rinse and repeat for "shipping" instead of "billing" if you also want to set the shipping address.

The following user(s) said Thank You: UPL

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

Time to create page: 0.055 seconds
Powered by Kunena Forum