Skip to content

Instantly share code, notes, and snippets.

@maximzasorin
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximzasorin/b675e86ac9e6478875dc to your computer and use it in GitHub Desktop.
Save maximzasorin/b675e86ac9e6478875dc to your computer and use it in GitHub Desktop.
Loading delivery methods for cart on HostCMS
(function($) {
$.extend({
loadDeliveries: function(path) {
var shop_country_id = $('#shop_country_id').val();
var shop_country_location_id = $('#shop_country_location_id').val();
var shop_country_location_city_id = $('#shop_country_location_city_id').val();
$.clientRequest({
path: path + '?ajaxLoad&getDeliveries&shop_country_id=' + shop_country_id
+ '&shop_country_location_id=' + shop_country_location_id
+ '&shop_country_location_city_id=' + shop_country_location_city_id,
callBack: $.clientSelectOptionsCallback,
context: $('#shop_delivery_condition_id')
});
}
});
})(jQuery);
<?php
// Libs/Shop/Cart -> ’Page Settings‘
if (!is_null(Core_Array::getGet('ajaxLoad')))
{
$aObjects = array();
if (!is_null(Core_Array::getGet('getDeliveries')))
{
$shop_country_id = intval(Core_Array::getGet('shop_country_id'));
$shop_country_location_id = intval(Core_Array::getGet('shop_country_location_id'));
$shop_country_location_city_id = intval(Core_Array::getGet('shop_country_location_city_id'));
$oShop_Delivery_Condition = new Shop_Delivery_Condition_Model();
$oShop_Delivery_Condition->queryBuilder()
->join(
'shop_deliveries',
'shop_delivery_conditions.shop_delivery_id', '=', 'shop_deliveries.id'
)
->where('shop_deliveries.active', '=', 1)
->where('shop_country_id', 'IN', Array($shop_country_id, 0))
->where('shop_country_location_id', 'IN', Array($shop_country_location_id, 0))
->where('shop_country_location_city_id', 'IN', Array($shop_country_location_city_id, 0))
->order('name');
$aObjects = $oShop_Delivery_Condition->findAll();
}
$aArray = array('…');
foreach ($aObjects as $Object)
{
$aArray['_' . $Object->id] = $Object->name;
}
echo json_encode($aArray);
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment