Issue #1347 fixed
This commit is contained in:
parent
973332f6c0
commit
8347e1770b
|
|
@ -423,7 +423,6 @@ class Cart {
|
|||
'customer_id' => $this->getCurrentCustomer()->user()->id,
|
||||
'is_active' => 1
|
||||
]);
|
||||
|
||||
} elseif (session()->has('cart')) {
|
||||
$cart = $this->cartRepository->find(session()->get('cart')->id);
|
||||
}
|
||||
|
|
@ -671,6 +670,8 @@ class Cart {
|
|||
return false;
|
||||
} else {
|
||||
foreach ($cart->items as $item) {
|
||||
$item->product->getTypeInstance()->validateCartItem($item);
|
||||
|
||||
$price = ! is_null($item->custom_price) ? $item->custom_price : $item->base_price;
|
||||
|
||||
$this->cartItemRepository->update([
|
||||
|
|
|
|||
|
|
@ -573,4 +573,26 @@ abstract class AbstractType
|
|||
{
|
||||
return $this->productImageHelper->getProductBaseImage($item->product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cart item product price
|
||||
*
|
||||
* @param CartItem $item
|
||||
* @return void
|
||||
*/
|
||||
public function validateCartItem($item)
|
||||
{
|
||||
$price = $item->product->getTypeInstance()->getFinalPrice();
|
||||
|
||||
if ($price == $item->base_price)
|
||||
return;
|
||||
|
||||
$item->base_price = $price;
|
||||
$item->price = core()->convertPrice($price);
|
||||
|
||||
$item->base_total = $price * $item->quantity;
|
||||
$item->total = core()->convertPrice($price * $item->quantity);
|
||||
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -441,4 +441,34 @@ class Bundle extends AbstractType
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cart item product price
|
||||
*
|
||||
* @param CartItem $item
|
||||
* @return void
|
||||
*/
|
||||
public function validateCartItem($item)
|
||||
{
|
||||
$price = 0;
|
||||
|
||||
foreach ($item->children as $childItem) {
|
||||
$childItem->product->getTypeInstance()->validateCartItem($childItem);
|
||||
|
||||
$price += $childItem->base_price * $childItem->quantity;
|
||||
}
|
||||
|
||||
if ($price == $item->base_price)
|
||||
return;
|
||||
|
||||
$item->base_price = $price;
|
||||
$item->price = core()->convertPrice($price);
|
||||
|
||||
$item->base_total = $price * $item->quantity;
|
||||
$item->total = core()->convertPrice($price * $item->quantity);
|
||||
|
||||
$item->additional = $this->getAdditionalOptions($item->additional);
|
||||
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -485,4 +485,26 @@ class Configurable extends AbstractType
|
|||
|
||||
return $this->productImageHelper->getProductBaseImage($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cart item product price
|
||||
*
|
||||
* @param CartItem $item
|
||||
* @return float
|
||||
*/
|
||||
public function validateCartItem($item)
|
||||
{
|
||||
$price = $item->child->product->getTypeInstance()->getFinalPrice();
|
||||
|
||||
if ($price == $item->base_price)
|
||||
return;
|
||||
|
||||
$item->base_price = $total;
|
||||
$item->price = core()->convertPrice($price);
|
||||
|
||||
$item->base_total = $price * $item->quantity;
|
||||
$item->total = core()->convertPrice($price * $item->quantity);
|
||||
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -215,4 +215,33 @@ class Downloadable extends AbstractType
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cart item product price
|
||||
*
|
||||
* @param CartItem $item
|
||||
* @return float
|
||||
*/
|
||||
public function validateCartItem($item)
|
||||
{
|
||||
$price = $item->product->getTypeInstance()->getFinalPrice();
|
||||
|
||||
foreach ($item->product->downloadable_links as $link) {
|
||||
if (! in_array($link->id, $item->additional['links']))
|
||||
continue;
|
||||
|
||||
$price += $link->price;
|
||||
}
|
||||
|
||||
if ($price == $item->base_price)
|
||||
return;
|
||||
|
||||
$item->base_price = $price;
|
||||
$item->price = core()->convertPrice($price);
|
||||
|
||||
$item->base_total = $price * $item->quantity;
|
||||
$item->total = core()->convertPrice($price * $item->quantity);
|
||||
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,8 @@ class CartController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
Cart::collectTotals();
|
||||
|
||||
return view($this->_config['view'])->with('cart', Cart::getCart());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@
|
|||
<?php $cart = cart()->getCart(); ?>
|
||||
|
||||
@if ($cart)
|
||||
@php
|
||||
Cart::collectTotals();
|
||||
@endphp
|
||||
|
||||
<?php $items = $cart->items; ?>
|
||||
|
||||
<div class="dropdown-toggle">
|
||||
|
|
|
|||
Loading…
Reference in New Issue