Cart item custom price implemented

This commit is contained in:
jitendra 2019-01-07 16:40:26 +05:30
parent 239d151887
commit 264e2b2a16
2 changed files with 17 additions and 9 deletions

View File

@ -790,11 +790,12 @@ 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;
$item->update([
'price' => $item->child->product->price,
'base_price' => $item->child->product->price,
'total' => core()->convertPrice($item->child->product->price * ($item->quantity)),
'base_total' => $item->child->product->price * ($item->quantity),
'price' => $price,
'base_price' => $price,
'total' => core()->convertPrice($price * ($item->quantity)),
'base_total' => $price * ($item->quantity),
]);
}
@ -806,11 +807,12 @@ 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;
$item->update([
'price' => $item->product->price,
'base_price' => $item->product->price,
'total' => core()->convertPrice($item->product->price * ($item->quantity)),
'base_total' => $item->product->price * ($item->quantity),
'price' => $price,
'base_price' => $price,
'total' => core()->convertPrice($price * ($item->quantity)),
'base_total' => $price * ($item->quantity),
]);
}
}

View File

@ -16,10 +16,16 @@ class CartItem extends Model
protected $guarded = ['id', 'created_at', 'updated_at'];
public function product() {
public function product()
{
return $this->hasOne(Product::class, 'id', 'product_id');
}
public function cart()
{
return $this->hasOne(Cart::class, 'id', 'cart_id');
}
/**
* Get the child item.
*/