effective_orders 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/order.rb +30 -15
- data/lib/effective_orders/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79642ded2e176dd43991e456466b69110f2e36ca107a9d49b5e1267ab57ed580
|
4
|
+
data.tar.gz: ec779c25f0fb3a8fcc55502105aa69e5a1d5586d2c4aedaef3bdbe4ad6194df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fabbafe0cb9d7a3dc19e559f369ffc90a5a11fb3da6388bea46d6a9ea42255973f2b7467fadaa0b6e5d6752e56f788b422f9483612c25aeb581ff18d4b50a6f
|
7
|
+
data.tar.gz: 2caec2a2464df534b68004d4050f7ab1d638c6c5c831b7a172dce582b64b61bf0c23fdd25dc517e316d3868e3d7973e6250735a91e4275f9d4180aacc1f607f7
|
@@ -114,24 +114,40 @@ module Effective
|
|
114
114
|
|
115
115
|
# Effective::Order.new()
|
116
116
|
# Effective::Order.new(Product.first)
|
117
|
-
# Effective::Order.new(Product.all)
|
118
|
-
# Effective::Order.new(Product.first, user: User.first)
|
119
|
-
# Effective::Order.new(Product.first, Product.second, user: User.first)
|
120
|
-
# Effective::Order.new(user: User.first)
|
121
117
|
# Effective::Order.new(current_cart)
|
118
|
+
# Effective::Order.new(Effective::Order.last)
|
122
119
|
|
123
|
-
#
|
124
|
-
|
125
|
-
|
120
|
+
# Effective::Order.new(items: Product.first)
|
121
|
+
# Effective::Order.new(items: [Product.first, Product.second], user: User.first)
|
122
|
+
# Effective::Order.new(items: Product.first, user: User.first, billing_address: Effective::Address.new, shipping_address: Effective::Address.new)
|
126
123
|
|
127
|
-
|
128
|
-
|
124
|
+
def initialize(atts = nil, &block)
|
125
|
+
super(purchase_state: EffectiveOrders::PENDING) # Initialize with state: PENDING
|
129
126
|
|
130
|
-
|
131
|
-
self.billing_address = billing_address if billing_address
|
132
|
-
self.shipping_address = shipping_address if shipping_address
|
127
|
+
return unless atts.present?
|
133
128
|
|
134
|
-
|
129
|
+
if atts.kind_of?(Hash)
|
130
|
+
items = Array(atts.delete(:item)) + Array(atts.delete(:items))
|
131
|
+
|
132
|
+
self.user = atts.delete(:user) || (items.first.user if items.first.respond_to?(:user))
|
133
|
+
|
134
|
+
if (address = atts.delete(:billing_address)).present?
|
135
|
+
self.billing_address = address
|
136
|
+
self.billing_address.full_name ||= user.to_s.presence
|
137
|
+
end
|
138
|
+
|
139
|
+
if (address = atts.delete(:shipping_address)).present?
|
140
|
+
self.shipping_address = address
|
141
|
+
self.shipping_address.full_name ||= user.to_s.presence
|
142
|
+
end
|
143
|
+
|
144
|
+
atts.each { |key, value| self.send("#{key}=", value) }
|
145
|
+
|
146
|
+
add(items) if items.present?
|
147
|
+
else # Attributes are not a Hash
|
148
|
+
self.user = atts.user if atts.respond_to?(:user)
|
149
|
+
add(atts)
|
150
|
+
end
|
135
151
|
end
|
136
152
|
|
137
153
|
# add(Product.first) => returns an Effective::OrderItem
|
@@ -169,8 +185,7 @@ module Effective
|
|
169
185
|
title: item.title,
|
170
186
|
quantity: item.quantity,
|
171
187
|
price: item.price,
|
172
|
-
tax_exempt: item.tax_exempt || false,
|
173
|
-
seller_id: (item.purchasable.try(:seller).try(:id) rescue nil)
|
188
|
+
tax_exempt: (item.tax_exempt || false),
|
174
189
|
).tap { |order_item| order_item.purchasable = item.purchasable }
|
175
190
|
end
|
176
191
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|