Cart issue fixed
This commit is contained in:
parent
264e2b2a16
commit
ce06916b3a
|
|
@ -284,26 +284,17 @@ class Cart {
|
|||
'weight' => $weight,
|
||||
'total_weight' => $weight * $data['quantity'],
|
||||
'base_total_weight' => $weight * $data['quantity'],
|
||||
'additional' => $additional
|
||||
'additional' => $additional,
|
||||
'type' => $product['type'],
|
||||
'product_id' => $product['id'],
|
||||
'additional' => $data,
|
||||
];
|
||||
|
||||
if($configurable){
|
||||
$parentData['type'] = $product['type'];
|
||||
$parentData['product_id'] = $product['id'];
|
||||
$parentData['additional'] = $data;
|
||||
} else {
|
||||
$parentData['type'] = $product['type'];
|
||||
$parentData['product_id'] = $product['id'];
|
||||
$parentData['additional'] = $data;
|
||||
}
|
||||
|
||||
if($configurable) {
|
||||
$additional = $this->getProductAttributeOptionDetails($parentProduct);
|
||||
$attributeDetails = $this->getProductAttributeOptionDetails($parentProduct);
|
||||
unset($attributeDetails['html']);
|
||||
|
||||
unset($additional['html']);
|
||||
|
||||
$additional['request'] = $data;
|
||||
$additional['variant_id'] = $data['selected_configurable_option'];
|
||||
$parentData['additional'] = array_merge($parentData['additional'], $attributeDetails);
|
||||
|
||||
$childData['product_id'] = (int)$data['selected_configurable_option'];
|
||||
$childData['sku'] = $parentProduct->sku;
|
||||
|
|
@ -333,6 +324,12 @@ class Cart {
|
|||
{
|
||||
$item = $this->cartItem->findOneByField('id', $itemId);
|
||||
|
||||
if (isset($data['product'])) {
|
||||
$additional = $data;
|
||||
} else {
|
||||
$additional = $item->additional;
|
||||
}
|
||||
|
||||
if($item->type == 'configurable') {
|
||||
$product = $this->product->findOneByField('id', $item->child->product_id);
|
||||
|
||||
|
|
@ -341,6 +338,11 @@ class Cart {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
$attributeDetails = $this->getProductAttributeOptionDetails($product);
|
||||
unset($attributeDetails['html']);
|
||||
|
||||
$additional = array_merge($additional, $attributeDetails);
|
||||
} else {
|
||||
$product = $this->product->findOneByField('id', $item->product_id);
|
||||
|
||||
|
|
@ -358,7 +360,8 @@ class Cart {
|
|||
'total' => core()->convertPrice($item->price * ($quantity)),
|
||||
'base_total' => $item->price * ($quantity),
|
||||
'total_weight' => $item->weight * ($quantity),
|
||||
'base_total_weight' => $item->weight * ($quantity)
|
||||
'base_total_weight' => $item->weight * ($quantity),
|
||||
'additional' => $additional
|
||||
]);
|
||||
|
||||
$this->collectTotals();
|
||||
|
|
@ -366,7 +369,7 @@ class Cart {
|
|||
if($result) {
|
||||
session()->flash('success', trans('shop::app.checkout.cart.quantity.success'));
|
||||
|
||||
return $result;
|
||||
return $item;
|
||||
} else {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.error'));
|
||||
|
||||
|
|
@ -790,7 +793,8 @@ class Cart {
|
|||
$item->update(['name' => $item->product->name]);
|
||||
|
||||
} else if($item->child->product->price != $item->price) {
|
||||
$price = $item->custom_price ? $item->custom_price : $item->child->product->price;
|
||||
$price = (float) $item->custom_price ? $item->custom_price : $item->child->product->price;
|
||||
|
||||
$item->update([
|
||||
'price' => $price,
|
||||
'base_price' => $price,
|
||||
|
|
@ -807,7 +811,8 @@ class Cart {
|
|||
$item->update(['name' => $item->product->name]);
|
||||
|
||||
} else if($item->product->price != $item->price) {
|
||||
$price = $item->custom_price ? $item->custom_price : $item->product->price;
|
||||
$price = (float) $item->custom_price ? $item->custom_price : $item->product->price;
|
||||
|
||||
$item->update([
|
||||
'price' => $price,
|
||||
'base_price' => $price,
|
||||
|
|
|
|||
Loading…
Reference in New Issue