1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

(feat) update cart created_at after add a new item when cart is empty

This commit is contained in:
Du Peng 2022-10-04 17:42:32 +02:00
parent 9066148572
commit 1104316e62

View File

@ -7,6 +7,8 @@ class Cart::AddItemService
raise Cart::InactiveProductError unless orderable.is_active
order.created_at = DateTime.current if order.order_items.length.zero?
item = order.order_items.find_by(orderable: orderable)
quantity = orderable.quantity_min > quantity.to_i && item.nil? ? orderable.quantity_min : quantity.to_i