Get customer email in MassAction PHP script

  • Posts: 1
  • Thank you received: 0
9 months 1 week ago #336737

The MassAction feature is perfect for what I want to do. I want to send JSON data to my API on the status change of a specific order. So I use the MassAction tool. Everything works fine and I can filter for my product and trigger a PHP script. The script does what it has to.

$url = "https://xyz.test:3535/newCustomerKey";

$user = $this->get($data->order_product_name);
echo $user;

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
"Accept: application/json",
"Content-Type: application/json",
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = <<<DATA
"key": 123,
"product": "XXX",
"customerEmail": "XXX"

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

$resp = curl_exec($curl);

Now the problem, how can I get the email of the customer from the order? When I echo $this I got "plgSystemHikashopmassaction".
On a custom Email Template i would do something like this: $user_email = @$customer->email;
Is there any way to get the data of the order from my custom script?
For the MassAction I use the trigger After an order is changed and filter on some stuff.

Thanks a lot for the help!

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

  • Posts: 76130
  • Thank you received: 11914
9 months 1 week ago #336742


You should be able to do it with something like that:

$orderClass = hikashop_get('class.order');
$order = $orderClass->get({order_id});
$userClass = hikashop_get('class.user');
$user = $userClass->get($order->order_user_id);
echo $user->user_email;

The following user(s) said Thank You: aftertaf

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

Time to create page: 0.035 seconds
Powered by Kunena Forum