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

Where to place the common ajax functions for shipping module plugin

 
Closed Thread
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-02-2015, 02:03 AM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

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

Default Where to place the common ajax functions for shipping module plugin

Where should I place my common ajax functions and can you please give me sample url on ajax calls?

I have got a new shipping methods but I don't know where should I place the ajax related functions specific to my plugin only?
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
  #2  
Old 08-02-2015, 02:17 AM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

Please note the following sample ajax call code. I have to use autocomplete jquery library thatswhy I am doing it normal jQuery way instead of some conventional X-Cart way:

jQuery("document").ready(function(){

jQuery("#shippingaddress-city").autocomplete('test', {
extraParams: {
countrycode: function() { return jQuery("#shippingaddress-country-code").val();},
city: function() { return jQuery("#shippingaddress-city").val(); }
},
minChars: 0,
max: 200,
multiple:false,
scrollHeight: 220,
autoFill: false,
mustMatch: false,
selectFirst:true,
cacheLength:1
});

jQuery("#shippingaddress-zipcode").autocomplete('test', {
extraParams: {
countrycode: function() { return jQuery("#shippingaddress-country-code").val();},
zip: function() { return jQuery("#shippingaddress-zipcode").val(); }
},
minChars: 0,
max: 200,
multiple:false,
scrollHeight: 220,
autoFill: false,
mustMatch: false,
selectFirst:false,
cacheLength:1
});

});
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
  #3  
Old 08-03-2015, 04:10 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

I think it may work if you add this js file to the list of js files loaded by the widget class.

However, it would be better if you could wrap it up into a "controller" and make XC5 autoload it - search for "core.autoload(" in other js files.
__________________
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
  #4  
Old 08-03-2015, 04:14 AM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

Sorry for not explaining clearly. I gave the example of jquery because I wanted to insert some xcart specific url to the autocomplete jquery function. So I mean to say that what sort of url should it be. Any example url? And where should I place the php related function which is going to be processed because this url is called.
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
  #5  
Old 08-05-2015, 11:46 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

It can be any URL pointing to a valid controller class. It's the controller and the view classes that should implement the AJAX logic.

If you need json response, use the WidgetsCollection controller as the example.
If you need html response (I believe so), check how the checkout controller reloads page sections.
__________________
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
  #6  
Old 08-06-2015, 01:50 AM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

Can you please give me some sample url of how it should be for the controller function or some documentation link which is giving an example of how to write the controller for a new plugin/shipping method?
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
  #7  
Old 08-16-2015, 09:59 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

Hello!

Please use the documentation at http://kb.x-cart.com/ for reference.

The article on creating a new controller is here:
http://kb.x-cart.com/display/XDD/Creating+new+page
__________________
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

The following user thanks qualiteam for this useful post:
aneel13 (08-17-2015)
  #8  
Old 08-17-2015, 08:32 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

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

Default Re: Where to place the common ajax functions for shipping module plugin

Thanks! Got it working with the controller functions
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Closed Thread
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:01 AM.

   

 
X-Cart forums © 2001-2020