// fix bug with missing $context->cart and $context->customer durring payment process
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13089 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+10
-5
@@ -504,11 +504,12 @@ class CarrierCore extends ObjectModel
|
||||
* @param Array $groups group of the customer
|
||||
* @return Array
|
||||
*/
|
||||
public static function getCarriersForOrder($id_zone, $groups = null)
|
||||
public static function getCarriersForOrder($id_zone, $groups = null, $cart = null)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_lang = $context->language->id;
|
||||
$cart = $context->cart;
|
||||
if (is_null($cart))
|
||||
$cart = $context->cart;
|
||||
$id_currency = $context->currency->id;
|
||||
|
||||
if (is_array($groups) && !empty($groups))
|
||||
@@ -1023,10 +1024,13 @@ class CarrierCore extends ObjectModel
|
||||
* @param Product $product The id of the product, or an array with at least the package size and weight
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null)
|
||||
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
|
||||
{
|
||||
if (is_null($id_shop))
|
||||
$id_shop = Context::getContext()->shop->getID(true);
|
||||
if (is_null($cart))
|
||||
$cart = Context::getContext()->cart;
|
||||
|
||||
|
||||
// Does the product is linked with carriers?
|
||||
$query = new DbQuery();
|
||||
@@ -1057,7 +1061,7 @@ class CarrierCore extends ObjectModel
|
||||
if (empty($carrier_list)) // No carriers defined, get all available carriers
|
||||
{
|
||||
$carrier_list = array();
|
||||
$id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery : Context::getContext()->cart->id_address_delivery);
|
||||
$id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery : $cart->id_address_delivery);
|
||||
if ($id_address)
|
||||
{
|
||||
$address = new Address($id_address);
|
||||
@@ -1068,7 +1072,8 @@ class CarrierCore extends ObjectModel
|
||||
$country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
$id_zone = $country->id_zone;
|
||||
}
|
||||
$carriers = Carrier::getCarriersForOrder($id_zone, Context::getContext()->customer->getGroups());
|
||||
$customer = new Customer($cart->id_customer);
|
||||
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart);
|
||||
foreach ($carriers as $carrier)
|
||||
$carrier_list[] = $carrier['id_carrier'];
|
||||
}
|
||||
|
||||
+1
-1
@@ -1479,7 +1479,7 @@ class CartCore extends ObjectModel
|
||||
else
|
||||
$key = (!$product['out_of_stock']) ? 'in_stock' : 'out_of_stock';
|
||||
|
||||
$product['carrier_list'] = Carrier::getAvailableCarrierList(new Product($product['id_product']), $id_warehouse, $product['id_address_delivery']);
|
||||
$product['carrier_list'] = Carrier::getAvailableCarrierList(new Product($product['id_product']), $id_warehouse, $product['id_address_delivery'], null, $this);
|
||||
|
||||
if (empty($product['carrier_list']))
|
||||
$product['carrier_list'] = array(0);
|
||||
|
||||
@@ -87,6 +87,7 @@ abstract class PaymentModuleCore extends Module
|
||||
$secure_key = false, Shop $shop = null)
|
||||
{
|
||||
$cart = new Cart($id_cart);
|
||||
$this->context->cart = $cart;
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
Reference in New Issue
Block a user