Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Different Checkout Fields On Change Country Event

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 07-11-2015, 10:28 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Different Checkout Fields On Change Country Event

I am looking into developing a new shipping module. But I am stucked in 2 initial areas of its developments:

1) I want the checkout fields (billing/shipping) change based on country selected. And the criteria for each country I am going to get from a service/API which will include which fields to show/hide and which fields are required/non-required. Meaning this has to be achieved in a way that as soon as the country changes, the service/API is called and based on its response the checkout fields against that country are shown in the checkout page along with a different validation rules. Please help me out, that how it could be achieved in X-Cart?

2) Another issue is that I want to keep the shipping/payment/review section hidden until the shipping/billing address fields are completely validated against my service/API. So what I am looking for is adding a next/continue button just below the checkout fields and only if the address is successfully validated against my service then only showing the right area which includes the shipping/payment/review section. The thing is I can't get the shipping charges for my shipping module until I validate my address fields against the service/API thatswhy, I am planning to keep it hidden until some charges are populated. Please let me know how this can be achieved aswell?


Regards,
Aneel
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #2  
Old 07-11-2015, 11:54 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Shipping Rates/Charges area dependent on user address

I want the shipping method to become visible only after I have validated the checkout address through some service/API and show some message like 'shipping address not validated' until the address is not validated to calculate rates.

Problem is that even with all shipping methods disabled from admin side, its still showing one shipping module active in front-end, don't know why. I want to see the X-Cart default state when all shipping methods are disabled.
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #3  
Old 07-13-2015, 11:35 PM
  razortw's Avatar 
razortw razortw is offline
 

X-Cart team
  
Join Date: Feb 2015
Posts: 807
 

Default Re: Shipping Rates/Charges area dependent on user address

Actually when all shipping methods are disabled, you should be seeing the message stating "Shipping methods are not available" on the checkout page. I attached a screenshot from my fresh XC 5.2.5 installation.
Which exactly shipping methods do you see in the customer front-end?
Thank you.
Attached Thumbnails
Click image for larger version

Name:	ssh.png
Views:	172
Size:	7.8 KB
ID:	4235  
__________________
Best regards,
Igor Pudovkin
X-Cart hosting team
Reply With Quote

The following user thanks razortw for this useful post:
aneel13 (07-27-2015)
  #4  
Old 07-18-2015, 02:45 AM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Re: Different Checkout Fields On Change Country Event

Yes I got that issue fixed when all shipping methods are disabled. Someone please help me out with the two issues posted in my first post. Those are the major hurdles preventing me to proceed with the plugin development.
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #5  
Old 07-20-2015, 01:12 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Different Checkout Fields On Change Country Event

Hello Aneel,

You can do both the points through a custom module only. X-Cart 5 has no such settings/services that you need.

Quote:
this has to be achieved in a way that as soon as the country changes, the service/API is called and based on its response the checkout fields against that country are shown in the checkout page along with a different validation rules

The checkout page is made of separate widgets and it is possible to trigger an AJAX widget reload through JavaScript. So, you may use the same technique that is used to reload the widget with shipping methods upon changing address fields. I'm not sure if I can name you exact files as there are many files used in that process.

Quote:
[I want to keep the shipping/payment/review section hidden until the shipping/billing address fields are completely validated

You may do this by assigning a CSS class to the container HTML tag and adding CSS that hides the sections if the container doesn't have the class.

Or you can go deeper and do the changes on the template level.

The base widget that renders the checkout pane is \XLite\View\Checkout
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
aneel13 (07-27-2015)
  #6  
Old 07-27-2015, 09:26 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Re: Different Checkout Fields On Change Country Event

Thanks for the response. Still its not clear how to go about. Let me give details on the problem again.

1) If I change country on checkout page, then an ajax call happens which first runs the service/API and gets the response and after the service response the fields needs to be changed on the frontend (e.g. for US no postal field, for UK no city field etc.). Meaning should I change the HTML at frontend accordingly as soon as I get the service response? But then the problem is the backend validation rules will apply differently, I need to change them aswell when place order is clicked. So what to call after my service response? Should I call some xcart function to update the fields which will automatically update the frontend html and backend validation rules?

2) I will make a separate ticket on the second issue. Because first one is dependent on it.
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #7  
Old 07-27-2015, 10:41 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Different Checkout Fields On Change Country Event

This is a complex modification and I'm not sure if I can explain it in a few words here in forums.

X-Cart reloads the HTML code from the server, so you don't need to manipulate the HTML code directly. Instead, you should customize the PHP classes that render the widgets. Use developer tools built-into your browser to see what AJAX requests are sent to reload the widgets - the requests look like the following one:
http://xcart/xc5/src/cart.php?target=checkout&action=&widget=%5CXLite%5 CView%5CCheckout%5CShippingMethod...43806902 9519
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
aneel13 (07-27-2015)
  #8  
Old 07-27-2015, 11:14 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Re: Different Checkout Fields On Change Country Event

Thanks. Do you mean to say that each of the widgets are loaded one by one through the server and I shouldn't manipulate the html directly but instead go for making changes to PHP classes and refreshing the widget by calling them through an additional ajax call?

The screen shot which you had attached is not available. Can you please attach that again. Atleast now I feel more confident on which is the correct way of going about this task

Can you also let me know which widget is responsible for refreshing the first part of checkout which is the shipping address fields?
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #9  
Old 07-27-2015, 11:17 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Re: Different Checkout Fields On Change Country Event

One more thing, if I am developing a new shipping module which is expected to perform the actions which I had previously stated. Then which areas of the xcart package can I touch so that when I export my plugin it has all the changes which are made by me.

Obviously I don't want to touch the core files, I believe it would be something like extending the core files in my plugin if I am not wrong.
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #10  
Old 07-30-2015, 04:52 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Different Checkout Fields On Change Country Event

Quote:
Originally Posted by aneel13
Thanks. Do you mean to say that each of the widgets are loaded one by one through the server and I shouldn't manipulate the html directly but instead go for making changes to PHP classes and refreshing the widget by calling them through an additional ajax call?

Yes, this is how the checkout page works now - PHP is the part that renders the HTML, JavaScript just loads the updated HTML form the server and replaces it in the browser.

Quote:
Originally Posted by aneel13
The screen shot which you had attached is not available.

It is not a screenshot It is a sample link for such a request - how it looks on my local server.

Quote:
Originally Posted by aneel13
Can you also let me know which widget is responsible for refreshing the first part of checkout which is the shipping address fields?

The widget that renders the first column with the address is this one:
\XLite\View\Checkout\ShippingAddress

Quote:
Originally Posted by aneel13
One more thing, if I am developing a new shipping module which is expected to perform the actions which I had previously stated. Then which areas of the xcart package can I touch so that when I export my plugin it has all the changes which are made by me.

Obviously I don't want to touch the core files, I believe it would be something like extending the core files in my plugin if I am not wrong.


Yes, you should not change core files. But you can use the ability to "decorate" them instead. Please search for "IDecorator" at http://kb.x-cart.com/ for articles on this matter.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
aneel13 (07-30-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:41 PM.

   

 
X-Cart forums © 2001-2020