// Improving method getAvailableCarrierList

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11648 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2011-12-22 17:37:27 +00:00
parent 4d288f7694
commit d0511c3211
2 changed files with 4 additions and 11 deletions
+3 -10
View File
@@ -1020,18 +1020,11 @@ class CarrierCore extends ObjectModel
* For a given {product, warehouse}, gets the carrier available * For a given {product, warehouse}, gets the carrier available
* *
* @since 1.5.0 * @since 1.5.0
* @param $product integer The id of the product, or an array with at least the package size and weight * @param Product $product The id of the product, or an array with at least the package size and weight
* @return array * @return array
*/ */
public static function getAvailableCarrierList($product, $id_warehouse, $id_shop = null) public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null)
{ {
if (is_numeric($product))
$product = new Product((int)$product);
else if (is_array($product))
{
$product['id'] = $product['id_product'];
$product = (object)$product;
}
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->getID(true);
@@ -1065,7 +1058,7 @@ class CarrierCore extends ObjectModel
if (empty($carrier_list)) // No carriers defined, get all available carriers if (empty($carrier_list)) // No carriers defined, get all available carriers
{ {
$carrier_list = array(); $carrier_list = array();
$id_address = ((isset($product->id_address_delivery) && $product->id_address_delivery != 0) ? $product->id_address_delivery : Context::getContext()->cart->id_address_delivery); $id_address = (!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery : Context::getContext()->cart->id_address_delivery;
$address = new Address($id_address); $address = new Address($id_address);
$id_zone = Address::getZoneById($address->id); $id_zone = Address::getZoneById($address->id);
$carriers = Carrier::getCarriersForOrder($id_zone, Context::getContext()->customer->getGroups()); $carriers = Carrier::getCarriersForOrder($id_zone, Context::getContext()->customer->getGroups());
+1 -1
View File
@@ -1459,7 +1459,7 @@ class CartCore extends ObjectModel
else else
$key = (!$product['out_of_stock']) ? 'in_stock' : 'out_of_stock'; $key = (!$product['out_of_stock']) ? 'in_stock' : 'out_of_stock';
$product['carrier_list'] = Carrier::getAvailableCarrierList($product, $id_warehouse); $product['carrier_list'] = Carrier::getAvailableCarrierList(new Product($product['id_product']), $id_warehouse, $product['id_address_delivery']);
if (empty($product['carrier_list'])) if (empty($product['carrier_list']))
$product['carrier_list'] = array(0); $product['carrier_list'] = array(0);