spree_temando 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +72 -0
- data/app/models/spree_temando/variant_shipping_decorator.rb +9 -1
- data/lib/spree_temando/version.rb +1 -1
- metadata +5 -21
data/README.md
CHANGED
@@ -55,6 +55,78 @@ It's important to note that all products in the cart must have their
|
|
55
55
|
dimensions filled out (height, length, depth, weight), otherwise Temando
|
56
56
|
will not be able to quote.
|
57
57
|
|
58
|
+
## Customisations
|
59
|
+
|
60
|
+
To simplify all the options for feeding product data to Temando, you can
|
61
|
+
define the `Spree::Variant#populate_temando_item` method, which will be
|
62
|
+
called back after the Variant has been turned into a Temando Item.
|
63
|
+
|
64
|
+
A few examples are included below to give you a hint at the
|
65
|
+
possibilities.
|
66
|
+
|
67
|
+
### Shipping Optimisations
|
68
|
+
|
69
|
+
The temando API allows for items to be identified as eligible for
|
70
|
+
optimisation (ie. they can be grouped together in a defined packaging
|
71
|
+
size), or ineligible for optimisation (ie. already packed and can't be
|
72
|
+
combined).
|
73
|
+
|
74
|
+
Because there are numerous different ways you might want to implement
|
75
|
+
this logic in your site, you must calculate this from the
|
76
|
+
`Spree::Variant#populate_temando_item` callback.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
module VariantDecorator
|
80
|
+
|
81
|
+
def populate_temando_item(item)
|
82
|
+
item.packaging_optimization = %w( Bundle Free ).include?(product.shipping_category.try(:name)) ? "Y" : "N"
|
83
|
+
|
84
|
+
item
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
Spree::Variant.send(:include, VariantDecorator)
|
89
|
+
```
|
90
|
+
|
91
|
+
The above example assumes that you're using a shipping category to
|
92
|
+
decide, and products in the "Bundle" or "Free" categories are
|
93
|
+
optimisable.
|
94
|
+
|
95
|
+
### Packaging Types
|
96
|
+
|
97
|
+
A similar situation arises with the shipping packaging. Because
|
98
|
+
different shipping methods are defined against different packaging types
|
99
|
+
(eg. parcels, pallets, etc) you often need to drive these from the
|
100
|
+
product categories.
|
101
|
+
|
102
|
+
To do this, you can adjust the Item returned by and set the correct
|
103
|
+
`shipping_packaging`. (See the Temando API for details on valid values).
|
104
|
+
|
105
|
+
The Temando gem defaults to `Parcel` packaging type if nothing is
|
106
|
+
explicitly set.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
module VariantDecorator
|
110
|
+
|
111
|
+
def populate_temando_item(item)
|
112
|
+
case product.shipping_category.try(:name)
|
113
|
+
when 'Pallet'
|
114
|
+
item.shipping_packaging = 'Pallet'
|
115
|
+
item.pallet_type = 'Plain'
|
116
|
+
item.pallet_nature = 'Not Required'
|
117
|
+
when 'Box'
|
118
|
+
item.shipping_packaging = 'Box'
|
119
|
+
else
|
120
|
+
item.shipping_packaging = 'Parcel'
|
121
|
+
end
|
122
|
+
|
123
|
+
item
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
Spree::Variant.send(:include, VariantDecorator)
|
128
|
+
```
|
129
|
+
|
58
130
|
## Notes
|
59
131
|
|
60
132
|
The extension only makes requests to the Temando API when the order
|
@@ -10,7 +10,12 @@ module SpreeTemando
|
|
10
10
|
def to_temando_item
|
11
11
|
return nil unless self.temando_quotable?
|
12
12
|
item = Temando::Item::GeneralGoods.new
|
13
|
-
|
13
|
+
|
14
|
+
if self.respond_to?(:packaging_optimization) then
|
15
|
+
Rails.logger.warn 'DEPRECATED: Spree::Variant#packaging_optimization. Use #populate_temando_item instead'
|
16
|
+
item.packaging_optimization = self.packaging_optimization
|
17
|
+
end
|
18
|
+
|
14
19
|
# NOTE: All the distances in Temando are in metres
|
15
20
|
item.height = (self.height / 100.0)
|
16
21
|
item.length = (self.depth / 100.0)
|
@@ -18,6 +23,9 @@ module SpreeTemando
|
|
18
23
|
item.weight = self.weight
|
19
24
|
item.quantity = 1
|
20
25
|
item.description = self.name
|
26
|
+
|
27
|
+
item = populate_temando_item(item) if self.respond_to?(:populate_temando_item)
|
28
|
+
|
21
29
|
item
|
22
30
|
end
|
23
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_temando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.1.
|
53
|
+
version: 0.1.4
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.4
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rspec
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,23 +92,7 @@ dependencies:
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: pry-remote
|
95
|
+
name: rake
|
112
96
|
requirement: !ruby/object:Gem::Requirement
|
113
97
|
none: false
|
114
98
|
requirements:
|