// Retrocompatibility with carriers modules
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12614 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+50
-4
@@ -1717,7 +1717,7 @@ class CartCore extends ObjectModel
|
||||
'carrier_list' => $best_price_carrier,
|
||||
'is_best_price' => true,
|
||||
'is_best_grade' => false,
|
||||
'unique_carrier' => false
|
||||
'unique_carrier' => (count($best_price_carrier) <= 1)
|
||||
);
|
||||
|
||||
$best_grade_carrier = array();
|
||||
@@ -1742,7 +1742,7 @@ class CartCore extends ObjectModel
|
||||
$delivery_option_list[$id_address][$key] = array(
|
||||
'carrier_list' => $best_grade_carrier,
|
||||
'is_best_price' => false,
|
||||
'unique_carrier' => false
|
||||
'unique_carrier' => (count($best_grade_carrier) <= 1)
|
||||
);
|
||||
|
||||
$delivery_option_list[$id_address][$key]['is_best_grade'] = true;
|
||||
@@ -1769,7 +1769,7 @@ class CartCore extends ObjectModel
|
||||
$delivery_option_list[$id_address][$key] = array(
|
||||
'is_best_price' => false,
|
||||
'is_best_grade' => false,
|
||||
'unique_carrier' => false,
|
||||
'unique_carrier' => true,
|
||||
'carrier_list' => array(
|
||||
$id_carrier => array(
|
||||
'price_with_tax' => $price_with_tax,
|
||||
@@ -1780,7 +1780,7 @@ class CartCore extends ObjectModel
|
||||
)
|
||||
);
|
||||
else
|
||||
$delivery_option_list[$id_address][$key]['unique_carrier'] = true;
|
||||
$delivery_option_list[$id_address][$key]['unique_carrier'] = (count($delivery_option_list[$id_address][$key]['carrier_list']) <= 1);
|
||||
}
|
||||
|
||||
foreach ($delivery_option_list as $id_address => $delivery_option)
|
||||
@@ -1810,6 +1810,23 @@ class CartCore extends ObjectModel
|
||||
$cache = $delivery_option_list;
|
||||
return $delivery_option_list;
|
||||
}
|
||||
|
||||
public function carrierIsSelected($id_carrier, $id_address)
|
||||
{
|
||||
$delivery_option = $this->getDeliveryOption();
|
||||
$delivery_option_list = $this->getDeliveryOptionList();
|
||||
|
||||
if (!isset($delivery_option[$id_address]))
|
||||
return false;
|
||||
|
||||
if (!isset($delivery_option_list[$id_address][$delivery_option[$id_address]]))
|
||||
return false;
|
||||
|
||||
if (!in_array($id_carrier, array_keys($delivery_option_list[$id_address][$delivery_option[$id_address]]['carrier_list'])))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all deliveries options available for the current cart formated like Carriers::getCarriersForOrder
|
||||
@@ -3137,4 +3154,33 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Execute hook displayCarrierList (extraCarrier) and merge theme to the $array
|
||||
* @param array $array
|
||||
*/
|
||||
public static function addExtraCarriers(&$array)
|
||||
{
|
||||
$first = true;
|
||||
$hook_extracarrier_addr = array();
|
||||
foreach (Context::getContext()->cart->getAddressCollection() as $address)
|
||||
{
|
||||
$hook = Hook::exec('displayCarrierList', array('address' => $address));
|
||||
$hook_extracarrier_addr[$address->id] = $hook;
|
||||
|
||||
if ($first)
|
||||
{
|
||||
$array = array_merge(
|
||||
$array,
|
||||
array('HOOK_EXTRACARRIER' => $hook)
|
||||
);
|
||||
$first = false;
|
||||
}
|
||||
$array = array_merge(
|
||||
$array,
|
||||
array('HOOK_EXTRACARRIER_ADDR' => $hook_extracarrier_addr)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user