magento 0.13.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/lib/magento.rb +3 -3
- data/lib/magento/guest_cart.rb +27 -0
- data/lib/magento/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df17670fd9bcb57f90cdb5cfdb17f098fc2e68676b32205d60db11609fdc346
|
4
|
+
data.tar.gz: 7ab232a58616a24b0b1c672d3d5d8e8510eda79c4f72b7baf85950d3c06f7895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3486c69930399a5b002ca33f014f1e5abc725c741d125790588bdadd472855b9858c6d1a596b07ac6e4e63e4069954bf75cc77b391ec06aec900fc868d5048f
|
7
|
+
data.tar.gz: 17f02541d592aa6fdc1211685bb0163bbaadb59f4f31d635b5b894a3f37c22082b19a8e55bbefc383831f8617c818685a23813648723adf6a6f380c1378d5162
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Add in your Gemfile
|
6
6
|
|
7
7
|
```rb
|
8
|
-
gem 'magento', '~> 0.
|
8
|
+
gem 'magento', '~> 0.14.0'
|
9
9
|
```
|
10
10
|
|
11
11
|
or run
|
@@ -339,6 +339,17 @@ cart.payment_information(
|
|
339
339
|
>> "234575" # return the order id
|
340
340
|
```
|
341
341
|
|
342
|
+
Add coupon to cart
|
343
|
+
```rb
|
344
|
+
cart = Magento::GuestCart.find('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
|
345
|
+
|
346
|
+
cart.add_coupon('COAU4HXE0I')
|
347
|
+
# You can also use the class method
|
348
|
+
Magento::GuestCart.add_coupon('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7', 'COAU4HXE0I')
|
349
|
+
|
350
|
+
>> true # return true on success
|
351
|
+
```
|
352
|
+
|
342
353
|
## Invoice an Order
|
343
354
|
|
344
355
|
```rb
|
data/lib/magento.rb
CHANGED
@@ -42,12 +42,12 @@ module Magento
|
|
42
42
|
self.token = ENV['MAGENTO_TOKEN']
|
43
43
|
self.store = ENV['MAGENTO_STORE'] || :all
|
44
44
|
|
45
|
-
def self.with_config(
|
45
|
+
def self.with_config(url: Magento.url, token: Magento.token, store: Magento.store)
|
46
46
|
@old_url = self.url
|
47
47
|
@old_token = self.token
|
48
48
|
@old_store = self.store
|
49
|
-
|
50
|
-
self.url =
|
49
|
+
|
50
|
+
self.url = url
|
51
51
|
self.token = token
|
52
52
|
self.store = store
|
53
53
|
|
data/lib/magento/guest_cart.rb
CHANGED
@@ -32,6 +32,18 @@ module Magento
|
|
32
32
|
self.class.payment_information(attributes)
|
33
33
|
end
|
34
34
|
|
35
|
+
#
|
36
|
+
# Add a coupon by code to the current cart.
|
37
|
+
#
|
38
|
+
# Example
|
39
|
+
# cart = Magento::GuestCart.find('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
|
40
|
+
# cart.add_coupon('COAU4HXE0I')
|
41
|
+
#
|
42
|
+
# @return Boolean: true on success, false otherwise
|
43
|
+
def add_coupon(coupon)
|
44
|
+
self.class.add_coupon(cart_id, coupon)
|
45
|
+
end
|
46
|
+
|
35
47
|
class << self
|
36
48
|
def create(load_cart_info: false)
|
37
49
|
cart = build(cart_id: request.post(api_resource).parse)
|
@@ -64,6 +76,21 @@ module Magento
|
|
64
76
|
hash = request.post(url, attributes).parse
|
65
77
|
Magento::ModelMapper.map_hash(Magento::Item, hash)
|
66
78
|
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Add a coupon by code to a specified cart.
|
82
|
+
#
|
83
|
+
# Example
|
84
|
+
# Magento::GuestCart.add_coupon(
|
85
|
+
# 'aj8oUtY1Qi44Fror6UWVN7ftX1idbBKN',
|
86
|
+
# 'COAU4HXE0I'
|
87
|
+
# )
|
88
|
+
#
|
89
|
+
# @return Boolean: true on success, false otherwise
|
90
|
+
def add_coupon(id, coupon)
|
91
|
+
url = "#{api_resource}/#{id}/coupons/#{coupon}"
|
92
|
+
request.put(url, nil).parse
|
93
|
+
end
|
67
94
|
end
|
68
95
|
end
|
69
96
|
end
|
data/lib/magento/version.rb
CHANGED