Issue #1779 fixed
This commit is contained in:
parent
05a619d39b
commit
dd1ca9336b
|
|
@ -597,9 +597,8 @@ abstract class AbstractType
|
|||
/**
|
||||
* Get request quantity
|
||||
*
|
||||
* @param Product $product
|
||||
* @param array $data
|
||||
* @return CartItem|void
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getQtyRequest($data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -419,6 +419,9 @@ class Bundle extends AbstractType
|
|||
return $cartProduct;
|
||||
|
||||
$cartProduct[0]['parent_id'] = $this->product->id;
|
||||
$cartProduct[0]['quantity'] = $data['quantity'];
|
||||
$cartProduct[0]['total_weight'] = $cartProduct[0]['weight'] * $data['quantity'];
|
||||
$cartProduct[0]['base_total_weight'] = $cartProduct[0]['weight'] * $data['quantity'];
|
||||
|
||||
$products = array_merge($products, $cartProduct);
|
||||
|
||||
|
|
@ -426,9 +429,9 @@ class Bundle extends AbstractType
|
|||
$products[0]['base_price'] += $cartProduct[0]['base_total'];
|
||||
$products[0]['total'] += $cartProduct[0]['total'];
|
||||
$products[0]['base_total'] += $cartProduct[0]['base_total'];
|
||||
$products[0]['weight'] += $cartProduct[0]['weight'];
|
||||
$products[0]['total_weight'] += $cartProduct[0]['total_weight'];
|
||||
$products[0]['base_total_weight'] += $cartProduct[0]['base_total_weight'];
|
||||
$products[0]['weight'] += ($cartProduct[0]['weight'] * $products[0]['quantity']);
|
||||
$products[0]['total_weight'] += ($cartProduct[0]['total_weight'] * $products[0]['quantity']);
|
||||
$products[0]['base_total_weight'] += ($cartProduct[0]['base_total_weight'] * $products[0]['quantity']);
|
||||
}
|
||||
|
||||
return $products;
|
||||
|
|
@ -483,7 +486,8 @@ class Bundle extends AbstractType
|
|||
if ($this->product->id != $options2['product_id'])
|
||||
return false;
|
||||
|
||||
return $options1['bundle_options'] == $options2['bundle_options'] && $options1['bundle_option_qty'] == $options2['bundle_option_qty'];
|
||||
return $options1['bundle_options'] == $options2['bundle_options']
|
||||
&& $options1['bundle_option_qty'] == $this->getOptionQuantities($options2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -506,6 +510,9 @@ class Bundle extends AbstractType
|
|||
$optionProduct = $this->productBundleOptionProductRepository->find($optionProductId);
|
||||
|
||||
$qty = $data['bundle_option_qty'][$optionId] ?? $optionProduct->qty;
|
||||
|
||||
if (! isset($data['bundle_option_qty'][$optionId]))
|
||||
$data['bundle_option_qty'][$optionId] = $qty;
|
||||
|
||||
$labels[] = $qty . ' x ' . $optionProduct->product->name . ' ' . core()->currency($optionProduct->product->getTypeInstance()->getMinimalPrice());
|
||||
}
|
||||
|
|
@ -522,6 +529,36 @@ class Bundle extends AbstractType
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns additional information for items
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionQuantities($data)
|
||||
{
|
||||
$optionQuantities = [];
|
||||
|
||||
foreach ($data['bundle_options'] as $optionId => $optionProductIds) {
|
||||
foreach ($optionProductIds as $optionProductId) {
|
||||
if (! $optionProductId)
|
||||
continue;
|
||||
|
||||
if (isset($data['bundle_option_qty'][$optionId])) {
|
||||
$optionQuantities[$optionId] = $data['bundle_option_qty'][$optionId];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$optionProduct = $this->productBundleOptionProductRepository->find($optionProductId);
|
||||
|
||||
$optionQuantities[$optionId] = $optionProduct->qty;
|
||||
}
|
||||
}
|
||||
|
||||
return $optionQuantities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cart item product price
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue