3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/seeds/workarea/discounts_seeds.rb', line 3
def perform
puts 'Adding discounts...'
Pricing::Discount::Shipping.create!(
name: 'Free Ground Shipping',
amount: 0,
shipping_service: Shipping::Service.asc(:created_at).first.name,
promo_codes: ['FREESHIPPING']
)
product = Catalog::Product.sample
Pricing::Discount::Product.create!(
name: "10% Off #{product.name} when 10 or more are purchased",
product_ids: [product.id],
item_quantity: 10,
amount: 10,
amount_type: :percent
)
category = Catalog::Category.sample
Pricing::Discount::Category.create!(
name: "15% Off all products in #{category.name}",
category_ids: [category.id],
amount: 15,
amount_type: :percent,
promo_codes: ['CATEGORY']
)
product = Catalog::Product.sample
product.details['Brand'] = ['Workarea']
product.save!
Pricing::Discount::ProductAttribute.create!(
name: '10% Off all Workarea Brand products',
attribute_name: 'Brand',
attribute_value: 'Workarea',
amount: 10,
amount_type: :percent
)
category = Catalog::Category.sample
Pricing::Discount::BuySomeGetSome.create!(
name: "Buy 2 Get 1 Free from #{category.name}",
purchase_quantity: 2,
apply_quantity: 1,
percent_off: 100,
category_ids: [category.id],
promo_codes: ['BUY2GET1']
)
product = Catalog::Product.where('variants.0' => { '$exists' => true }).sample
category = Catalog::Category.sample
Pricing::Discount::FreeGift.create!(
name: "Free Gift when purchasing a product from #{category.name}",
sku: product.skus.sample,
category_ids: [category.id],
promo_codes: ['FREEGIFT']
)
Pricing::Discount::OrderTotal.create!(
name: '10% Off Order',
amount_type: 'percent',
amount: 10,
promo_codes: ['10PERCENTOFF']
)
category = Catalog::Category.sample
Pricing::Discount::QuantityFixedPrice.create!(
name: 'Products, 2 for $25',
quantity: 2,
price: 25,
category_ids: [category.id],
promo_codes: ['2FOR25']
)
end
|