diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 506bf4616..48325c583 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -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), ]); } } diff --git a/packages/Webkul/Checkout/src/Models/CartItem.php b/packages/Webkul/Checkout/src/Models/CartItem.php index 1f9628149..caca3cc01 100755 --- a/packages/Webkul/Checkout/src/Models/CartItem.php +++ b/packages/Webkul/Checkout/src/Models/CartItem.php @@ -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. */