Last active
August 29, 2015 14:25
-
-
Save maximzasorin/b675e86ac9e6478875dc to your computer and use it in GitHub Desktop.
Loading delivery methods for cart on HostCMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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