magento 0.14.0 → 0.15.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 +15 -2
- data/lib/magento/guest_cart.rb +23 -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: 0d7a340d50d7233fcb8e0eb877d49e1c29e0785fb76413c2216bf79c86bb420b
|
4
|
+
data.tar.gz: 6c1ad15d2b246e145d7d83082749431d89303f9c82a6fe74dd525ed52615fe28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1e2e8fc442888fc6cd2e45f16d10186a1abf86ca990517cd0b9dbba60b2a57d015c9af2dc25e93d492413491cc4e7e1c37efa479c8e74581ce319b5d623a1ec
|
7
|
+
data.tar.gz: 219111f025c6189e6c83605e6a08f0479e1080e7ae40ff8f740aa0190df298ab71ef3b1c6c8a3757466e5a74b4d78e64c50827ad84da0a7b1a47774e6571aff8
|
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.15.0'
|
9
9
|
```
|
10
10
|
|
11
11
|
or run
|
@@ -350,6 +350,17 @@ Magento::GuestCart.add_coupon('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7', 'COAU4HXE0I')
|
|
350
350
|
>> true # return true on success
|
351
351
|
```
|
352
352
|
|
353
|
+
Delete coupon from cart
|
354
|
+
```rb
|
355
|
+
cart = Magento::GuestCart.find('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
|
356
|
+
|
357
|
+
cart.delete_coupon()
|
358
|
+
# You can also use the class method
|
359
|
+
Magento::GuestCart.delete_coupon('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
|
360
|
+
|
361
|
+
>> true # return true on success
|
362
|
+
```
|
363
|
+
|
353
364
|
## Invoice an Order
|
354
365
|
|
355
366
|
```rb
|
@@ -551,7 +562,7 @@ rule = Magento::SalesRule.create(
|
|
551
562
|
rule.generate_coupon(quantity: 1, length: 10)
|
552
563
|
```
|
553
564
|
|
554
|
-
|
565
|
+
Generate by class method
|
555
566
|
```rb
|
556
567
|
Magento::SalesRule.generate_coupon(
|
557
568
|
couponSpec: {
|
@@ -564,6 +575,8 @@ Magento::SalesRule.generate_coupon(
|
|
564
575
|
see all params in:
|
565
576
|
- [Magento docs Coupon](https://magento.redoc.ly/2.3.5-admin/tag/couponsgenerate#operation/salesRuleCouponManagementV1GeneratePost)
|
566
577
|
- [Magento docs SalesRules](https://magento.redoc.ly/2.3.5-admin/tag/salesRules#operation/salesRuleRuleRepositoryV1SavePost)
|
578
|
+
|
579
|
+
See [how to add coupons to cart](#guestcart)
|
567
580
|
|
568
581
|
### First result
|
569
582
|
```rb
|
data/lib/magento/guest_cart.rb
CHANGED
@@ -44,6 +44,17 @@ module Magento
|
|
44
44
|
self.class.add_coupon(cart_id, coupon)
|
45
45
|
end
|
46
46
|
|
47
|
+
# Delete cart's coupon
|
48
|
+
#
|
49
|
+
# Example:
|
50
|
+
# cart = Magento::GuestCart.find('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
|
51
|
+
# cart.delete_coupon()
|
52
|
+
#
|
53
|
+
# @return Boolean: true on success, raise exception otherwise
|
54
|
+
def delete_coupon
|
55
|
+
self.class.delete_coupon(cart_id)
|
56
|
+
end
|
57
|
+
|
47
58
|
class << self
|
48
59
|
def create(load_cart_info: false)
|
49
60
|
cart = build(cart_id: request.post(api_resource).parse)
|
@@ -91,6 +102,18 @@ module Magento
|
|
91
102
|
url = "#{api_resource}/#{id}/coupons/#{coupon}"
|
92
103
|
request.put(url, nil).parse
|
93
104
|
end
|
105
|
+
|
106
|
+
#
|
107
|
+
# Delete a coupon from a specified cart.
|
108
|
+
#
|
109
|
+
# Example:
|
110
|
+
# Magento::GuestCart.delete_coupon('aj8oUtY1Qi44Fror6UWVN7ftX1idbBKN')
|
111
|
+
#
|
112
|
+
# @return Boolean: true on success, raise exception otherwise
|
113
|
+
def delete_coupon(id)
|
114
|
+
url = "#{api_resource}/#{id}/coupons"
|
115
|
+
request.delete(url).parse
|
116
|
+
end
|
94
117
|
end
|
95
118
|
end
|
96
119
|
end
|
data/lib/magento/version.rb
CHANGED