[Skip to main content](#vessel-content)

#   Accessing customer details onAfterOrderCreate

##

- **[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")**
- [![rodfarrell's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/5859-rodfarrell "View rodfarrell's Profile") Topic Author
- [ Offline](/forum/user/5859-rodfarrell)

Less More

- Posts: 259
- Thank you received: 22
-
-

1 year 11 months ago [\#364765](#364765) by [rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")  *[Accessing customer details onAfterOrderCreate](/forum/44-mass-actions/908933-accessing-customer-details-onafterordercreate#364765 "I'm writing a php script to add a customer's details to a MailerLite list after an order is created. How do I call the customers email address and name into variables?")* was created by *[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")*

I'm writing a php script to add a customer's details to a MailerLite list after an order is created. How do I call the customers email address and name into variables?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ0LW1hc3MtYWN0aW9ucy85MDg5MzMtYWNjZXNzaW5nLWN1c3RvbWVyLWRldGFpbHMtb25hZnRlcm9yZGVyY3JlYXRlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14279
-
-

1 year 11 months ago [\#364766](#364766) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Accessing customer details onAfterOrderCreate](/forum/44-mass-actions/908933-accessing-customer-details-onafterordercreate#364766 "I'm writing a php script to add a customer's details to a MailerLite list after an order is created. How do I call the customers email address and name into variables?")*

Hi,

So, in the onAfterOrderCreate event, you have a parameter $order as explained here:
[ www.hikashop.com/support/documentation/6...l#onAfterOrderCreate](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onAfterOrderCreate)
You'll find the id of the user in $order-&gt;order_user_id
And you can retrieve the information of the user with such code: Code:

$userClass = hikashop_get('class.user'); $user = $userClass-&gt;get($order-&gt;order_user_id); echo $user-&gt;user_email; // this is the email stored in HikaShop. This will always be available echo $user-&gt;name; // this is the name of the user stored in the Joomla user account. This won't be available if the order is created as a guest checkout // supposing the user provided a billing address during the checkout, you'll have the information of the address in $order-&gt;cart-&gt;billing_address echo $order-&gt;cart-&gt;billing_address-&gt;address_firstname; // this would provide the first name of the user in the billing address of the order

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ0LW1hc3MtYWN0aW9ucy85MDg5MzMtYWNjZXNzaW5nLWN1c3RvbWVyLWRldGFpbHMtb25hZnRlcm9yZGVyY3JlYXRlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")**
- [![rodfarrell's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/5859-rodfarrell "View rodfarrell's Profile") Topic Author
- [ Offline](/forum/user/5859-rodfarrell)

Less More

- Posts: 259
- Thank you received: 22
-
-

1 year 11 months ago -  1 year 11 months ago [\#364786](#364786) by [rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")  Replied by *[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")* on topic *[Accessing customer details onAfterOrderCreate](/forum/44-mass-actions/908933-accessing-customer-details-onafterordercreate#364786 "I'm writing a php script to add a customer's details to a MailerLite list after an order is created. How do I call the customers email address and name into variables?")*

Thanks. I am missing something here. $order is not defined but I thought the trigger After an Order is Created should do that?

Warning: Undefined variable $order in /home/joomlawe/findmorestars/plugins/system/hikashopmassaction/hikashopmassaction.php(1963) : eval()'d code on line 3
[ ![screenshot-findmorestars&#95;com-2024&#95;12&#95;03-09&#95;55&#95;34.png](/forum/attachment/60058) ](/forum/attachment/60058 "...3-09&#95;55&#95;34.png")

- [ ![screenshot-findmorestars&#95;com-2024&#95;12&#95;03-09&#95;55&#95;34.png](/forum/attachment/60058) ](/forum/attachment/60058 "...3-09&#95;55&#95;34.png") [ ](/forum/attachment/60058?download=1 "...3-09&#95;55&#95;34.png")

Last edit: 1 year 11 months ago by [rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ0LW1hc3MtYWN0aW9ucy85MDg5MzMtYWNjZXNzaW5nLWN1c3RvbWVyLWRldGFpbHMtb25hZnRlcm9yZGVyY3JlYXRlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14279
-
-

1 year 10 months ago [\#364789](#364789) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Accessing customer details onAfterOrderCreate](/forum/44-mass-actions/908933-accessing-customer-details-onafterordercreate#364789 "I'm writing a php script to add a customer's details to a MailerLite list after an order is created. How do I call the customers email address and name into variables?")*

Hi,

In your first message, you talked about onAfterOrderCreate.
That's an event fired by HikaShop, which plugins of the groups "hikashop", "hikashopshipping", "hikashoppayment" or "system" can subscribe to by defining a method for it as explained here:
[ www.hikashop.com/support/documentation/6...mentation.html#intro](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#intro)

Based on your new screenshot, I now understand that you're actually not using the onAfterOrderCreate event.
Instead, you've created a massaction with a trigger "after an order is created" and you're using the "run PHP code" action in order to try to achieve a similar result as a plugin.
In the PHP code of a "run PHP code" action, you don't have access to any existing variable like $order.
You only have access to tags on the element being processed:
[ www.hikashop.com/support/documentation/1...action-form.html#php](https://www.hikashop.com/support/documentation/167-massaction-form.html#php)
So, you can't use the code of my previous message "as is". You need to adapt it. For example: Code:

$orderClass = hikashop_get('class.order'); $order = $orderClass-&gt;loadFullOrder({order_id}, true, false); echo $order-&gt;customer-&gt;user_email; // this is the email stored in HikaShop. This will always be available echo $order-&gt;customer-&gt;name; // this is the name of the user stored in the Joomla user account. This won't be available if the order is created as a guest checkout // supposing the user provided a billing address during the checkout, you'll have the information of the address in $order-&gt;billing_address echo $order-&gt;billing_address-&gt;address_firstname; // this would provide the first name of the user in the billing address of the order

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ0LW1hc3MtYWN0aW9ucy85MDg5MzMtYWNjZXNzaW5nLWN1c3RvbWVyLWRldGFpbHMtb25hZnRlcm9yZGVyY3JlYXRlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")**
- [![rodfarrell's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/5859-rodfarrell "View rodfarrell's Profile") Topic Author
- [ Offline](/forum/user/5859-rodfarrell)

Less More

- Posts: 259
- Thank you received: 22
-
-

1 year 10 months ago [\#364840](#364840) by [rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")  Replied by *[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")* on topic *[Accessing customer details onAfterOrderCreate](/forum/44-mass-actions/908933-accessing-customer-details-onafterordercreate#364840 "I'm writing a php script to add a customer's details to a MailerLite list after an order is created. How do I call the customers email address and name into variables?")*

Sorry for the misunderstanding. I presumed incorrectly that Mass Actions used the same event trigger. Your solution works perfectly and customers purchasing my intro product now get added to the MailerLite sales funnel. Thanks for your help.

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ0LW1hc3MtYWN0aW9ucy85MDg5MzMtYWNjZXNzaW5nLWN1c3RvbWVyLWRldGFpbHMtb25hZnRlcm9yZGVyY3JlYXRlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.079 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
