effective_orders 4.1.0 → 4.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f15a457703f171efde10a8a750dcd7b8c7092e3f
4
- data.tar.gz: 182e31f6db68aac1ff8f6a50fdf405f5e3307ae5
3
+ metadata.gz: af4efa3c792e1b34f177d52b18445ce7f30be3d5
4
+ data.tar.gz: 30263da58a648a93672514ad67bdd2b141ca38b1
5
5
  SHA512:
6
- metadata.gz: 0ed4b21b9c7d9bd6ad1ac9615874b1735eb69826bd5db89ab18df7f96889a8282edcd1ca37b363e6e4f0dcc0001c608a83df431b8e6ab7361d5633ca1f2b3326
7
- data.tar.gz: d59aa7963b0436533fbf99fbe9e1d6ee79dbdbf8278b7d361fde6e16187023e935436492a7b04a1d4df80d682d7b4725e4e6ebb2fe4233c40ad993a9861cc691
6
+ metadata.gz: 30d73984681fde16edb4bc2656302365075fb4a0786cb81c83f22cb0c150629faec7fb776fc3c0662c5711d7d7831d84c50aadb64bfc4f85797b666506fa352f
7
+ data.tar.gz: 95d334d4f35d525e4e25de0c1260379895405f3cbe346fe12525fe604989ee095f0a4d9a08a3043f9accda42acdb86e0e62c1d076c8199be48406d067f2f0025
@@ -24,8 +24,8 @@ $(document).on 'change keyup', '.effective-orders-subscripter-plan-quantity', (e
24
24
 
25
25
  quantity = $obj.val() || 0
26
26
 
27
- # Assign all totals
28
27
  $plan.closest('form').find(".effective-orders-stripe-plan").each ->
28
+ # Assign all totals
29
29
  plan = $(this)
30
30
  amount = parseInt(plan.data('amount'))
31
31
  interval = plan.data('plan-interval')
@@ -37,6 +37,13 @@ $(document).on 'change keyup', '.effective-orders-subscripter-plan-quantity', (e
37
37
 
38
38
  plan.find('#effective_subscripter_total_amount').text(total)
39
39
 
40
+ # Assign savings if present
41
+ savings = parseInt(plan.data('savings'))
42
+
43
+ if savings > 0
44
+ total_savings = '$' + ((quantity * savings) / 100.0).toFixed(2)
45
+ plan.find('.subscripter-total-savings').find('span').text(total_savings)
46
+
40
47
  # Hijack submit and get a stripe token
41
48
  $(document).on 'click', ".effective-orders-stripe-token-required[type='submit'],[data-choose-stripe-plan-id]", (event) ->
42
49
  $obj = $(event.currentTarget)
@@ -45,7 +45,7 @@ module ActsAsSubscribable
45
45
 
46
46
  def subscripter
47
47
  @_effective_subscripter ||= begin
48
- Effective::Subscripter.new(subscribable: self, user: subscribable_buyer, quantity: (subscription&.quantity || 0), stripe_plan_id: subscription&.stripe_plan_id)
48
+ Effective::Subscripter.new(subscribable: self, user: subscribable_buyer, quantity: subscription&.quantity, stripe_plan_id: subscription&.stripe_plan_id)
49
49
  end
50
50
  end
51
51
 
@@ -46,8 +46,8 @@ module Effective
46
46
  EffectiveOrders.stripe_plans[stripe_plan_id]
47
47
  end
48
48
 
49
- def quantity
50
- (@quantity.to_i if @quantity.present?)
49
+ def quantity=(value)
50
+ @quantity = (value.to_i if value)
51
51
  end
52
52
 
53
53
  def token_required?
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '4.1.0'.freeze
2
+ VERSION = '4.1.1'.freeze
3
3
  end
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: 4.1.0
4
+ version: 4.1.1
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-04-02 00:00:00.000000000 Z
11
+ date: 2019-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails