On onestepcheckout page, in billing section we have a country field select box, on selecting country from drop-down, ajax request is send and the selected country is set as billing address's country. I want to create a country drop down with same functionality on cart page. I have created the country select box using the following code
<?php $_countries = Mage::getModel('directory/country')
->getResourceCollection()
->loadByStore()
->toOptionArray(true);?>
and using foreach loop to show the options in a select box. Now I have problem with the functionality. On onestepcheckout page when the country is selected, an ajax request is send and the following country gets selected. I am trying to copy this process but could not succeed.Here is my ajax code in cart.phtml file
jQuery('#country').change(function(){
var countryName = (jQuery(this).val());
jQuery.ajax({
type: 'POST',
url: "<?php echo $this->getUrl('checkout/cart/estimatePost')?>",
data: {'country_id' : countryName},
success: function(data){
alert(data);
}
}); });
On onestepcheckout page ajax request hits the following url
url: "<?php echo $this->getUrl('onestepcheckout/ajax/save_billing')?>"
I am trying to copy this function on cart page but could not understand how to proceed. Please any one have any idea on how to proceed.
save_billingAction() in Ajaxcontroller.php has lot of functionalities which I could not understand. I just want to save the country so that when the page is reloaded that country is set as billing address's country. Any one could help me how to proceed