- Posts: 1
- Thank you received: 0
Get customer email in MassAction PHP script
4 years 10 months ago #336737
by Valle
Get customer email in MassAction PHP script was created by Valle
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.
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!
Code:
$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"
}
DATA;
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$resp = curl_exec($curl);
curl_close($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.
4 years 10 months ago #336742
by nicolas
Replied by nicolas on topic Get customer email in MassAction PHP script
Hi,
You should be able to do it with something like that:
You should be able to do it with something like that:
Code:
$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.212 seconds