User order info

  • Posts: 1
  • Thank you received: 0
5 years 5 months ago #307482

Hi am developing a plugin for hikashop and I do not know how to get the following info for my plugin
Is it something like $user->address1?
P.S I am new to Joomla development

"first_name"
"last_name"
"email"
"phone"
"country"
"region"
"address1"
"address2"
"city"
"zip"

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 5 months ago #307486

Hi,

The exact code to get the address of the user will depend in which trigger you want to do that. Could you provide more information on that ?
Supposing that you have the user_id of the user from the hikashop_user table in the variable $user_id, and supposing that HikaShop is already loaded, you can use such code to get the addresses of the user:

$addressClass = hikashop_get('class.address');
$addresses = $addressClass->loadUserAddresses($user_id);

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

  • Posts: 2
  • Thank you received: 0
5 years 5 months ago #307540

After a user pays I want his info to be sent via post

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 5 months ago #307544

Hi,

So in that case, I would recommend to implement the "onAfterOrderUpdate(&$order)" trigger in a plugin of the group "hikashop".
In it, you would first check the new and old status, and then load the order data and get the info of the billing address:

if($order->order_status != $order->old->order_status && $order->order_status == 'confirmed') {
 $orderClass = hikashop_get('class.order');
 $orderData = $orderClass->loadFullOrder($order->order_id, false, false);
 echo $orderData->billing_address->address_city;
 // etc
}

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

  • Posts: 2
  • Thank you received: 0
5 years 5 months ago #307566

What about name and other info?

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 5 months ago #307573

Hi,

It's the same as for the city, just replace the address_city with the column name of the custom address field you want. You can see the column names in the menu Display>Custom fields of HikaShop.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum