mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
13 lines
309 B
Ruby
13 lines
309 B
Ruby
class Cart < ActiveRecord::Base
|
|
has_many :orders, :class_name => 'Spree::Order'
|
|
belongs_to :user, :class_name => Spree.user_class
|
|
|
|
def add_variant variant, quantity
|
|
if orders.empty?
|
|
order = Spree::Order.create
|
|
order.add_variant(variant, quantity)
|
|
orders << order
|
|
end
|
|
end
|
|
end
|