Display user custom field data in checkout cart

  • Posts: 8
  • Thank you received: 0
10 years 2 months ago #194870

-- url of the page with the problem -- : atelieraman.com
-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

Hi,
I am collecting some measurements from the user in the user table through custom fields. I need those measurements to appear in the cart at checkout, in a column after the product name and before the quantity and price. I have found the checkout cart view, but how do I call the data from the fields?

Also, is there any way I can have multiple measurement sets that the user can choose form, like I can have multiple addresses?
Thanks,
Irina

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

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 2 months ago #194895

Hi,

In the checkout/cart view, that you can edit under the menu Display>Views, you can use such code:
<?php
$user = hikashop_loadUser(true);
echo $user->custom_field;
?>

Where custom_field is the column name of your custom field of the table user.
The custom user fields do not support multiple sets of data per user like custom address fields, which are made for that. I don't see an easy way to do that for custom user fields beside creating several times the same fields.

The following user(s) said Thank You: AMAN

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

  • Posts: 8
  • Thank you received: 0
10 years 2 months ago #195188

That works great, thank you!
Can you also give me the code for displaying the custom filed label as well as the value?
Thank you so much for your help!
Irina

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

  • Posts: 8
  • Thank you received: 0
10 years 2 months ago #195209

Can you please also let me know how to make that show up in the email notification as well?

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

  • Posts: 8
  • Thank you received: 0
10 years 2 months ago #195228

Thank you so much for your help!
Another question now, since I can't write php: how can I display the content of a custom field from a previous checkout step in the checkout cart?
I have an observations custom field in the fields checkout view, and I want to show those observations in a td in the cart in the last checkout step.
Thanks!

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

  • Posts: 8
  • Thank you received: 0
10 years 2 months ago #195239

Ok,I inserted this code:
<?php
$user = hikashop_loadUser(true);
echo $user->custom_field;
?>

in the backend, order_additional view, to preserve the measurements. The problem is that is reading the info of the admin not of the customer. What modifications should I make to read the customer's data?

Thanks!

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

  • Posts: 26235
  • Thank you received: 4036
  • MODERATOR
10 years 2 months ago #195273

Hi,

Yes in the email you can also use PHP yes (but the "loadUser" will load the current user).
So you can use $data->customer to access to the order customer.
Or you can also use the HikaShop email tags like

{VAR:user.custom_field}

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: AMAN

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

Time to create page: 0.070 seconds
Powered by Kunena Forum