Add custom fields to shopping cart and notification emails

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
3 weeks 30 minutes ago #358706

-- HikaShop version -- : 5.0.2
-- Joomla version -- : 3.10.12
-- PHP version -- : 7.4

Hi,

I have three questions.

  1. I created a custom field; how do I show it in the cart drop-down?
  2. The user should log in or register as a Guest before checkout. How can I add the customer address information on the registration page to the admin emails
  3. How can I add the customer address information to the email subject line?

Thanks.

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
2 weeks 6 days ago #358708

Hi,

1. Please provide a screenshot of the settings of the custom field.
I checked your website, but I couldn't find products, nor a cart drop down. Could you please provide more context on this ?

2. The customer billing and shipping address will be automatically included on the order admin notification email and the payment notification email which are sent once the customer finishes the checkout and the order is created. So I'm not sure what you mean. Could you please provide more context on this too ?

3. There is no easy way to do that. You'll have to edit the email via the menu System>Emails. There, in the HTML area, you can change the email subject with code like this:

<php $mail->subject = 'My custom email subject with a custom address field: ' . $data->cart->biilling_address->address_firstname; ?>
So it requires a bit of PHP coding.

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
2 weeks 6 days ago #358711

This is the custom field screenshot:


I will email you the admin credentials to check it.

Thanks.

Attachments:

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
2 weeks 6 days ago #358712

Hi,

Ok, so I understand you want to display a custom field of the table "product" in the HikaShop cart module you have displayed at the top of your pages. Is that correct ?
There is no option to display it there. Since there is not much space there, we decided not to provide that possibility.
So, if you want to do that, you'll have to edit the view file product / cart via the menu Display>Views and add custom PHP code to display the custom field there manually.
For example, after the code:

echo $product->product_name;
which displays the product name, you could add :
echo $product->productid;
in order to display the value in the custom field of your screenshot.

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
2 weeks 6 days ago #358729

That code solved the problem.
Is there any quick way to change the shopping cart dropdown width?

Also, we used the shopping cart for quoting and removed all the prices.
In checkout, the user only fills out the address fields for registration, and we don't ask for billing or shipping addresses. How can I add the user address information in the admin emails?

Thanks.

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
2 weeks 5 days ago #358737

Hi,

1. You can add such CSS code to your website:

div.hikashop_cart_dropdown_content { width: 500px; }

2. If the user filled the address fields of HikaShop during the registration, then the checkout should automatically use the address entered during the registration as the billing and the shipping address of the order. So normally, there should be nothing to do for that. So I'm surprised you're asking about this.
How does the admin emails look at the moment on your website ? Did you customize it ?
Also, I checked your settings with the access you provided earlier, and I can see you've turned off the "Ask address on registration" setting of the HikaShop configuration. In that case, HikaShop won't ask his address to the customer during the registration, contrary to what you said. So I'm a bit lost in trying to understand the current situation you're in to be able to say what you need to do.

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
2 weeks 4 days ago #358785

On the front end, the user needs to fill out the address form before checkout


Also, on the backend, the "Ask address on the registration" field is enabled:

I only removed the price from the admin notification email template, which doesn't show the address in the email preview or notification email. You can change the admin email in the backend and test it if you want.

Thanks.

Attachments:

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
2 weeks 4 days ago #358787

Hi,

You say " which doesn't show the address in the email preview or notification email.", but you don't have any order with an address in it so you can't test the address display in the emails with them.
Look at the details of the two orders you have configured via the Orders menu. They don't have any address set. And if there are no addresses set in the order, the email notification won't be able to display one.
I suppose that you simply created these orders when you had the address form deactivated from your checkout.
So either add an address to an existing order, or create a new order from the frontend (which will have an address), and you'll see the address in the preview for that ordar.

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
2 weeks 4 days ago #358819

Hi,

What about registered users? They can log in and checkout without filling out the address fields.
How can I add the registered user address data to the admin notification emails?

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
2 weeks 1 day ago #358838

Hi,

That's because you removed the "address" view from your "checkout workflow".
Please add it back between the "login" and the "cart" view and it won't happen.

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
2 weeks 1 day ago #358862

Hi,

I added the address field between the "login" and the "cart" view; why email doesn't show custom address fields? like as a Company

?


Also, how can I modify the alignment of this code {TXT:CUSTOMFIELD_NAME} in the emails?

Attachments:
Last edit: 2 weeks 1 day ago by omnitron.

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
2 weeks 20 hours ago #358868

Hi,

I do see the address now in the email.
The address display in the emails and the invoice uses the "address format" you have in the HikaShop configuration, under the Checkout tab. So if you add extra address fields, you need to add them in that "address format" setting too if you want them to appear in the emails.
For the alignment of custom product fields in the products listing of the emails, you want to look in the "preload" of the email via the menu System>Emails. There, search for "text-align:right".

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
1 week 6 days ago #358933

Hi,

I added it to the Address box in the backend

,
but it still doesn't show in the emails.

Attachments:

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
1 week 5 days ago #358938

Hi,

With the backend access you had created before, I checked your custom fields, but you don't have any "address_industry" custom field and the "address_company" field is not published on your website. Instead, you've created two fields "industry" and "company". so you need to change your tags in the address format so that they correspond to the column name of your custom fields.

The following user(s) said Thank You: omnitron

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
1 week 1 day ago #359021

Hi

I added the provided code to the HTML section, and it worked.
"<php $mail->subject = 'My custom email subject with a custom address field: ' . $data->cart->billing_address->address_firstname; ?>"
Can I add more fields, such as State and County, to the subject?

Thanks.

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

  • Posts: 81090
  • Thank you received: 12976
  • MODERATOR
1 week 20 hours ago #359025

Hi,

Sure. The code should be similar:

<?php $mail->subject = 'My custom email subject with a custom address field: ' . $data->cart->billing_address->xxx; ?>
where xxx can be replaced by the column name of any address field you want to use.
Now, what exact code you want to use depends on what exact subject you want your emails to have...

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

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
10 hours 34 minutes ago #359231

Hi,

Can I add two or more address fields to the subject line?
For example, "My custom email subject with a custom address field: xxx1 , xxx2" ?
<?php $mail->subject = 'My custom email subject with a custom address field: ' . $data->cart->billing_address->xxx; ',' . $data->cart->billing_address->xxx1; ?>

Thanks.

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

Time to create page: 0.125 seconds
Powered by Kunena Forum