Integrating an address autocomplete into the checkout address form

  • Posts: 59
  • Thank you received: 2
6 years 4 months ago #295714

-- url of the page with the problem -- : avonrivercomputers.com.au/hikatest
-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.10
-- PHP version -- : 7.1
-- Browser(s) name and version -- : Firefox 61.0.1

I know my version of Hikashop is out of date, I have just created this quick and dirty site to try and incorporate an address autocomplete javascript widget. I have found a provider called addressfinder.com.au Once integrated into the form page, when the user starts to type in an address into a field, it will put up suggestions based on the next typed text. This also displays street number, street, suburb state and postcode. This means that there will be no typos because the user will see their address and select that instead of having to type it in. A client of mine has had to try and decipher street addresses that are spelled incorrectly, and also people who forget to change the state combo box and that shows up wrong when trying to create a shipping label. Addressfinder.com.au will generate a javascript based on what you require and this seems to work correctly. What i need to know is where do I place the generated Javascript code to get this to work in the Hikashop checkout form. I thought I should place it in the Views>Address>Frontend but there are 5 different places where I could put it and not being a coder, am not sure where to place it within the file/s Any help would be greatly appreciated, Steve

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 4 months ago #295716

Hi,

Since it's likely on the registration form that you want to add that and that you're using the checkout of HikaShop 3 (not the legacy, old, one of HikaShop 2), you want to add your javascript to the file "show_block_login" via the menu Display>Views.
Note that you'll have to modify the code given to you to change the ids of the elements.
For example, instead of address_line_1, you'll want to use address_street which is the column name and ID of the field that you want to use for the interactive widget.
Note also that for the state, the dropdown has a specific namekey for each state and doesn't just use the state name or the state code. So the javascript code would have to be adapted to match them manually.

The following user(s) said Thank You: avonrivercs

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

  • Posts: 59
  • Thank you received: 2
6 years 4 months ago #295783

Thanks Nicolas, that worked perfectly :)

The following user(s) said Thank You: nicolas

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

  • Posts: 59
  • Thank you received: 2
6 years 4 months ago #295845

Hi Nicolas,
Your suggestions worked on my test site, but when I tried to copy the code from the test site to the live site, all looks good until I save the checkout / show_block_login.php file, it removes everything from the file and just shows a blank sheet. Going to the front end shows no account form. The only way to get it back is to delete the customization which returns back to the default. I have updated the test site Hikashop to 3.5.1 and also upgraded the live site from 3.5.0 to 3.5.1. I have set the legacy checkout to no in the live site which has caused some other styling issues, but these can be dealt with over time. My main concern is that when I modify the file and save, it removes all of the code and leaves an empty file. All the best, Steve
Update: Just tested and changed a <H1> tag to a <H2> and corresponding </H1> and </H2> and saved and that was enough to delete the entire code from the file. So to be clear, any modification to the file results in no modifications and no code left in the file. Steve
Update 2: URL in question is balancedequine.com.au/

[Moderator :] Don't edit your message a long time after post it, if you have elements to add post a new message, please that mess up our work organisation.

Last edit: 6 years 4 months ago by Philip.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 4 months ago #295852

Hi,

Yes, that's a common issue caused by a security extension / software on your website / server.
In that case, you want to do the override manually via FTP in order to circumvent the security or seek out your system administrator or hosting for help:
docs.joomla.org/How_to_override_the_outp...rom_the_Joomla!_core

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

  • Posts: 59
  • Thank you received: 2
6 years 4 months ago #295873

The link you gave shows how to do overrides. While this may be a solution, I think it is beyond my capabilities and another learning process with associated time that I do not have. I did disable ModSec in Cpanel, but this did nothing. Could I manually make a copy of the checkout / show_block_login.php file and edit the file directly on the server? If so, where do I look to find this file?

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

  • Posts: 59
  • Thank you received: 2
6 years 4 months ago #295874

Update: I found the file in question using Cpanel and edited the file there. It is working although I a bit worried about future ramifications of doing it this way. Anyway working correctly and addresses are offering suggestions and all fields are auto populating. I had to change the state field from a zone to text. This doesn't matter as the widget fills in the correct state anyway. Thanks for all your help, all the best, Steve

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 4 months ago #295875

Hi,

Well, the link I gave explains where you need to copy the file:
TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php
So in the case of that view file, it would be:
templates/YOUR_TEMPLATE/html/com_hikashop/checkout/show_block_login.php
That way, you won't loose the change when you update.

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

  • Posts: 59
  • Thank you received: 2
6 years 3 months ago #295901

Hi Nicolas,
While the code widget works perfectly on the registration form, it does not work on the edit Address or edit Shipping forms. My thoughts are that these forms are displaying from different files. Which files do I need to edit in order to get the same functionality on these forms. Thanks for your help before, I have copied the original file to the location you suggested above and would think that other view files should be stored there also, correct? All the best, Steve

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

  • Posts: 12953
  • Thank you received: 1778
6 years 3 months ago #295911

Hello,

If you want to edit the code of the file display addresses through your checkout, you'll have to edit the code of the " show_block_address" file of the "checkout" view of your front-end template.

For more information about views modification :
www.hikashop.com/support/documentation/1...-display.html#layout

Best regards,
Mohamed Thelji.

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

  • Posts: 59
  • Thank you received: 2
6 years 3 months ago #296040

Hi Mohamed,
The code that I inserted into the show_block_login works perfectly and displays suggestions for addresses based on letters typed. When an address is selected all fields auto populate which is what I want. I have inserted the same code into the show_block_address, when I want to edit an existing address or shipping address, the widget doesn't work and looking at the console view, it says "Input element was null" suggesting that this isn't the file that I need to edit to get this to work. Are you sure that the edit address or edit shipping is actually the show_block_address?

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 3 months ago #296041

Hi,

The code needs to be adapted for the show_block_address as the ids are not the same between the two forms.
And yes, it's the show_block_address view where you need to add your code for the address form.

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

Time to create page: 0.092 seconds
Powered by Kunena Forum