Merge pull request #2061 from jitendra-webkul/1.0

Issue #2054 fixed
This commit is contained in:
Jitendra Singh 2020-01-15 19:03:59 +05:30 committed by GitHub
commit d931571c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 1 deletions

View File

@ -405,7 +405,9 @@ class Bundle extends AbstractType
*/
public function prepareForCart($data)
{
if (! isset($data['bundle_options']))
$data['bundle_options'] = array_filter($this->validateBundleOptionForCart($data['bundle_options']));
if (! isset($data['bundle_options']) || ! count($data['bundle_options']))
return trans('shop::app.checkout.cart.integrity.missing_options');
$products = parent::prepareForCart($data);
@ -490,6 +492,27 @@ class Bundle extends AbstractType
&& $options1['bundle_option_qty'] == $this->getOptionQuantities($options2);
}
/**
* Remove invalid options from add to cart request
*
* @param array $data
* @return array
*/
public function validateBundleOptionForCart($data)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
$data[$key] = $this->validateBundleOptionForCart($value);
} elseif ($value && $value) {
$data[$key] = (int)$value;
} else {
unset($data[$key]);
}
}
return $data;
}
/**
* Returns additional information for items
*