File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -111,19 +111,19 @@ class QuantityDiscount
111
111
def initialize ( quantityDiscount )
112
112
@discount = quantityDiscount
113
113
end
114
-
114
+
115
115
def apply ( line_item )
116
116
# Find quantityDiscount Object - Get Quantity/Discount
117
117
quantity , discount = @discount . find do |quantity , _ |
118
118
line_item . quantity >= quantity
119
119
end
120
-
120
+
121
121
# Calculated the discounted line price using the line discount.
122
122
discount_price = line_item . line_price - ( Money . new ( cents :100 ) * discount * line_item . quantity )
123
-
123
+
124
124
#Caculate Total Discount
125
125
total_discount = Decimal . new ( discount * line_item . quantity ) + 0.01
126
-
126
+
127
127
# Set Message.
128
128
message = "$#{ discount } off per item when buying more than #{ quantity - 1 } . You saved $#{ total_discount - 0.01 } !"
129
129
@@ -151,7 +151,7 @@ def apply(line_item)
151
151
) ,
152
152
QuantityDiscount . new ( TopSeller ) ,
153
153
) ,
154
-
154
+
155
155
# Quantity Breaks for Individual
156
156
BulkItemCampaign . new (
157
157
Individual ,
@@ -161,7 +161,7 @@ def apply(line_item)
161
161
) ,
162
162
QuantityDiscount . new ( Individual ) ,
163
163
) ,
164
-
164
+
165
165
# Quantity Breaks for Pocket Guides
166
166
BulkItemCampaign . new (
167
167
PocketGuide ,
You can’t perform that action at this time.
0 commit comments