how to add my custom fields to billing/delivery address?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

how to add my custom fields to billing/delivery address?

Post by Ahmad » 04 Apr 2020, 13:47

hello, in the checkout delivery section, i want to add my custom fields to form and save it with order, i want to add a select options input for states list and select options input for cities list, when customer select an state the cities list change according to selected state?how can i do it?

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: how to add my custom fields to billing/delivery address?

Post by aimeos » 06 Apr 2020, 06:43

You can add fields in the delivery step dynamically by implementing a service decorator you configure on top of the delivery service:
- https://aimeos.org/docs/Developers/Library/Service
- https://aimeos.org/docs/Developers/Libr ... _decorator

You can define the countries and states by configuration:
https://aimeos.org/docs/Laravel/Configu ... ons_states

You should read https://aimeos.org/docs/Laravel where you can find links to articles answering the most common questions.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

Re: how to add my custom fields to billing/delivery address?

Post by Ahmad » 06 Apr 2020, 10:11

@aimeos please give me a solution by my question, you just repeat document contents, i don't say anything about country, i just say about state and cities, please pay attention, i need help and without your help i don't know how to do for process my steps.

i don't need country list because i just want to sell in one country but in this country i need state list and after user choose a state this list of cities change and show cities of the selected state to chose by user.

i can do this in laravel but i want to don't change in checkout route, can i create another checkout with another route like shop.com/mycheckout for this?

you say change in delivery step but i want to get user info in address step.

Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

Re: how to add my custom fields to billing/delivery address?

Post by Ahmad » 06 Apr 2020, 10:14

aimeos wrote: 06 Apr 2020, 06:43 You can add fields in the delivery step dynamically by implementing a service decorator you configure on top of the delivery service:
- https://aimeos.org/docs/Developers/Library/Service
- https://aimeos.org/docs/Developers/Libr ... _decorator

You can define the countries and states by configuration:
https://aimeos.org/docs/Laravel/Configu ... ons_states

You should read https://aimeos.org/docs/Laravel where you can find links to articles answering the most common questions.
@aimeos
please and please and please help me in a simple and clear way to fix my problem with aimeos:

i want to change checkout process like this:
customer add this field for billing and delivery address:
First Name-Last Name-Mobile Number-Telephone Number-State (choose from select box)-City (choose from select box)-Address-Additional

when customer choose state (state change) options in the City select box change according to selected state ( i mean show cities of chosen state)
after customer selected city (i have a city id), my Delivery service price updated with send data (include city_id, products_price and products_total_weights) to third party logistic company API and get shipping price and set for delivery cost
i want to happen this in one page not step by step
and after that show summary and set order;
please give me a simple solution, i did a search and found that your system is very, very, very complicated, please give me right solution don't refer me to a few different articles.

Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

Re: how to add my custom fields to billing/delivery address?

Post by Ahmad » 08 Apr 2020, 11:14

i'm waiting for your answer official aimeos.

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: how to add my custom fields to billing/delivery address?

Post by aimeos » 08 Apr 2020, 16:56

For the state selection, you can change the address partial and add your states there:
https://github.com/aimeos/ai-client-htm ... #L209-L236

Maybe its best if you do what you want to do in your own Laravel controller and replace the checkout component with your own code. Doing this in a one page checkout in Aimeos is possible but requires some Javascript and JSON REST API calls and lookking at your current posts it might be not as easy to explain as you need it so you can understand it.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

Re: how to add my custom fields to billing/delivery address?

Post by Ahmad » 09 Apr 2020, 08:50

aimeos wrote: 08 Apr 2020, 16:56 For the state selection, you can change the address partial and add your states there:
https://github.com/aimeos/ai-client-htm ... #L209-L236

Maybe its best if you do what you want to do in your own Laravel controller and replace the checkout component with your own code. Doing this in a one page checkout in Aimeos is possible but requires some Javascript and JSON REST API calls and lookking at your current posts it might be not as easy to explain as you need it so you can understand it.
thanks, i add my own decorator and change checkout address templates, with own decorator i use addData() method and add my custom states and cities list, i have 2 question in this step, please help me:
1- what is best way to add my custom javascript functions like as (on change state list input element change event)?where can i add this function to the javascript code?create own javascript app or add function in aimeos-demo js files?

2- are my own address partial inputs like as (order.base.address.city_id) store in session and Autofill basket plug-in and when user refresh the page or go to next step and back to address step autofill on input?

3- can i change my own delivery service price with JSON REST API before user go to deliver step?i mean i want to when user select or fill city input in checkout/address step, send ajax request to JSON REST API and calcPrice() with the request data and store it, after that when user click on next and go to checkout/deliver step my own delivery service show with calculated price,
in current time i do it with calcPrice() method in ServiceProvider but i worry about it because i should be send data with SOAP request to API of my third party logestic service provider to calculate the postal price and it may be take a few seconds to get price or catch with exception with server unreachable and and the user does not know that he/she has to wait for calcPrice.

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: how to add my custom fields to billing/delivery address?

Post by aimeos » 10 Apr 2020, 12:59

Ahmad wrote: 09 Apr 2020, 08:50 1- what is best way to add my custom javascript functions like as (on change state list input element change event)?where can i add this function to the javascript code?create own javascript app or add function in aimeos-demo js files?
You can add it to your public/js/app.js file for example.
Ahmad wrote: 09 Apr 2020, 08:50 2- are my own address partial inputs like as (order.base.address.city_id) store in session and Autofill basket plug-in and when user refresh the page or go to next step and back to address step autofill on input?
No, they are not stored. You have to extend the customer address item so the fromArray() method will store that data in the item:
https://aimeos.org/docs/Developers/Libr ... Custom_way
Ahmad wrote: 09 Apr 2020, 08:50 3- can i change my own delivery service price with JSON REST API before user go to deliver step?i mean i want to when user select or fill city input in checkout/address step, send ajax request to JSON REST API and calcPrice() with the request data and store it, after that when user click on next and go to checkout/deliver step my own delivery service show with calculated price,
in current time i do it with calcPrice() method in ServiceProvider but i worry about it because i should be send data with SOAP request to API of my third party logestic service provider to calculate the postal price and it may be take a few seconds to get price or catch with exception with server unreachable and and the user does not know that he/she has to wait for calcPrice.
You should store at least the result of the API call to the logistic provider in the session so it's only requested once and not for each submit of the customer within the checkout process or basket. If you add the address to the basket with a POST request to the JSON REST API, then you can use a GET request to the service endpoint of the JSON REST API to retrieve the result of the logistic provider in the background. But I don't know if that is a good idea because if the customer clicks on the "Next" button before the response arives, it's sent twice and you don't have any advantage.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply