// Fix bug with gift products and multishipping
This commit is contained in:
+7
-4
@@ -1442,8 +1442,11 @@ class CartCore extends ObjectModel
|
||||
if (!$flag)
|
||||
$cart_rules[] = $tmp_cart_rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']);
|
||||
$package = array('id_carrier' => $id_carrier, 'id_address' => $id_address_delivery, 'products' => $products);
|
||||
|
||||
// Then, calculate the contextual value for each one
|
||||
foreach ($cart_rules as $cart_rule)
|
||||
{
|
||||
@@ -1463,14 +1466,12 @@ class CartCore extends ObjectModel
|
||||
$in_order = true;
|
||||
|
||||
if ($in_order)
|
||||
$order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, null, CartRule::FILTER_ACTION_GIFT);
|
||||
$order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, null, CartRule::FILTER_ACTION_GIFT, $package);
|
||||
}
|
||||
|
||||
// If the cart rule offers a reduction, the amount is prorated (with the products in the package)
|
||||
if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0)
|
||||
{
|
||||
$id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']);
|
||||
$package = array('id_carrier' => $id_carrier, 'id_address' => $id_address_delivery, 'products' => $products);
|
||||
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package), 2);
|
||||
}
|
||||
}
|
||||
@@ -2700,6 +2701,8 @@ class CartCore extends ObjectModel
|
||||
$gift_product['total'] = 0;
|
||||
$gift_product['gift'] = true;
|
||||
$gift_products[] = $gift_product;
|
||||
|
||||
break; // One gift product per cart rule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,10 +593,7 @@ class CartRuleCore extends ObjectModel
|
||||
}
|
||||
if ($countMatchingProducts < $productRuleGroup['quantity'])
|
||||
return (!$display_error) ? false : Tools::displayError('You cannot use this voucher with these products');
|
||||
// p($matchingProductsList);
|
||||
// p($eligibleProductsList);
|
||||
$eligibleProductsList = CartRule::array_uintersect($eligibleProductsList, $matchingProductsList);
|
||||
// d($eligibleProductsList);
|
||||
break;
|
||||
case 'categories':
|
||||
$cartCategories = Db::getInstance()->executeS('
|
||||
@@ -890,6 +887,7 @@ class CartRuleCore extends ObjectModel
|
||||
$reduction_value += ($use_tax ? $product['price_wt'] : $product['price']);
|
||||
if (!isset(CartRule::$only_one_gift[$this->id.'-'.$this->gift_product]) || CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] == 0)
|
||||
CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] = $id_address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +247,8 @@ abstract class PaymentModuleCore extends Module
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $cart->getProducts();
|
||||
$cart_rules = $cart->getCartRules();
|
||||
foreach ($order_detail_list as $key => $order_detail)
|
||||
{
|
||||
$order = $order_list[$key];
|
||||
@@ -275,7 +277,6 @@ abstract class PaymentModuleCore extends Module
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
$products = $cart->getProducts();
|
||||
foreach ($products as $key => $product)
|
||||
{
|
||||
$price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
@@ -327,7 +328,7 @@ abstract class PaymentModuleCore extends Module
|
||||
} // end foreach ($products)
|
||||
|
||||
$cart_rules_list = '';
|
||||
foreach ($cart->getCartRules() as $cart_rule)
|
||||
foreach ($cart_rules as $cart_rule)
|
||||
{
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
|
||||
Reference in New Issue
Block a user