Page 1 of 1

How to refresh services on the basis of country change

Posted: 13 Mar 2019, 08:12
by awaidqureshi
How i can refresh services on the basis of country selection on one page checkout page

For reference:
Address Form: https://prnt.sc/mx642u
Service :http://prntscr.com/mx64d2
both are on the same page so how we can change the services option please help about it.

Thanks.

How to submit billing or delivery address form in aimeos

Posted: 13 Mar 2019, 16:39
by awaidqureshi
we are using one page checkout when user change the billing address services are not changing
Like if some delivery service is country specific so when i change the country it should not show that service which is showing because of old address we r using .

Is there any method so that we can update services part on country change (We r using one page checkout our billing address,delivery address services and payment options are on the same page).
Please give help about it.
Thanks.

Re: How to refresh services on the basis of country change

Posted: 13 Mar 2019, 20:07
by aimeos
You have to use the Aimeos JSON REST API to add the address and get the services afterwards:
https://aimeos.org/docs/Developers/Client/JSONAPI

Re: How to refresh services on the basis of country change

Posted: 14 Mar 2019, 07:50
by awaidqureshi
aimeos wrote:You have to use the Aimeos JSON REST API to add the address and get the services afterwards:
https://aimeos.org/docs/Developers/Client/JSONAPI

Thanks for your reply, yeah we're using the jsonapi already prior to your reply. :) . Just wanted to confirm whether there were any alternative methods available but doesn't look like it.

All right so, once we use the API to adjust the basket and the delivery options, we have to render the relevant delivery services on the page without refreshing the entire page. Do you have any suggestions on how we should go about doing that? I think submitting the entire form just to be able to update the delivery options is not really great in terms of the overall user experience.

Code on country change
http://prntscr.com/mxnmfb
Error:
http://prntscr.com/mxnoaw
Please tell me step by step guide.

Danke im Vorhaus!

Re: How to refresh services on the basis of country change

Posted: 14 Mar 2019, 08:50
by aimeos
The checkout component contains a "data-jsonapi" attribute with the link to the API. Fetch that link first during page load to get the available resources. Afterwards, you can use the "basket" resource link to get the basket content. The response contains the CSRF token and the link to add the address. Post the address data and retrieve the delivery/payment options using the service resource. The response will contain only those services that are valid according to the basket content (which depends on the decorators you've added to the services). Afterwards, you can render the services into the existing section from the response, maybe by using Vue.JS