camaleon_ecommerce 2.0.1 → 2.0.2

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: ffe51c8728a07203d61723294fae8e931f98bb83
4
- data.tar.gz: 0dca114bd0e607778e360ec6c8875b8320e6b6bb
3
+ metadata.gz: 259fb7c0d7425357cf85f22b4dd36c09f0f793a1
4
+ data.tar.gz: bca5fac0b47ff2f37795d54e7db45474bc6be598
5
5
  SHA512:
6
- metadata.gz: 2ebe61b791a3bd949fd84bac6a0436be89fa9a3dbabcb365f8070c9178f993313f352aa57ff1ef4e038c6e87cce6f261089f2beb569640abfa0893e724bd3491
7
- data.tar.gz: c452b792eb61ae54fdf1a19b76f2a271bd263f2f5f880e6ec3be23e1a1f5e071659b99b181e4690e604bf759ca2b681f85fe6bc31bc95eb9e5d5fe23d9d30565
6
+ metadata.gz: faa588f0e928cac0e0432e3762ca57444b4cde51193eef635a882cd353828fb6cd325ef8825715ed21ebb79711222a33958b573f91f1a1ab4c20302c05b84c9e
7
+ data.tar.gz: 64fb1190c45c2a0a1fc0207d24864914e57505f8892526006bb812d8488107f2cab49e542f3e2d884058ab78078b6e4dfb20b2931d1655d5c15ea8c849ac7657
@@ -32,7 +32,7 @@ class Plugins::Ecommerce::Front::CheckoutController < Plugins::Ecommerce::FrontC
32
32
  errors = ecommerce_verify_cart_errors(@cart)
33
33
  if errors.present?
34
34
  flash[:cama_ecommerce][:error] = errors.join('<br>')
35
- redirect_to :back
35
+ redirect_to request.referer
36
36
  else
37
37
  hooks_run('plugin_ecommerce_before_complete_free_order', @cart)
38
38
  @cart.set_meta('free_order', true)
@@ -42,7 +42,7 @@ class Plugins::Ecommerce::Front::CheckoutController < Plugins::Ecommerce::FrontC
42
42
  end
43
43
  else
44
44
  flash[:cama_ecommerce][:error] = "Invalid complete payment"
45
- redirect_to :back
45
+ redirect_to request.referer
46
46
  end
47
47
  end
48
48
 
@@ -74,7 +74,7 @@ class Plugins::Ecommerce::Front::CheckoutController < Plugins::Ecommerce::FrontC
74
74
 
75
75
  unless product.can_added?(qty, params[:variation_id])
76
76
  flash[:cama_ecommerce][:error] = t('plugins.ecommerce.messages.not_enough_product_qty', product: product.the_variation_title(params[:variation_id]), qty: product.the_qty(params[:variation_id]), default: 'There is not enough products "%{product}" (Available %{qty})')
77
- return params[:format] == 'json' ? render(json: flash.discard(:cama_ecommerce).to_hash) : (redirect_to :back)
77
+ return params[:format] == 'json' ? render(json: flash.discard(:cama_ecommerce).to_hash) : (redirect_to request.referer)
78
78
  end
79
79
  @cart.add_product(product, qty, params[:variation_id])
80
80
  flash[:cama_ecommerce][:notice] = t('plugins.ecommerce.messages.added_product_in_cart', default: 'Product added into cart')
@@ -121,7 +121,7 @@ class Plugins::Ecommerce::Front::CheckoutController < Plugins::Ecommerce::FrontC
121
121
  if result[:payment_error]
122
122
  flash[:payment_error] = true
123
123
  end
124
- redirect_to :back
124
+ redirect_to request.referer
125
125
  else
126
126
  commerce_mark_cart_received(@cart)
127
127
  redirect_to plugins_ecommerce_orders_url
@@ -153,7 +153,7 @@ class Plugins::Ecommerce::Front::CheckoutController < Plugins::Ecommerce::FrontC
153
153
  if res[:error].present?
154
154
  flash[:cama_ecommerce][:error] = res[:error]
155
155
  flash[:payment_error] = true
156
- redirect_to :back
156
+ redirect_to request.referer
157
157
  else
158
158
  commerce_mark_cart_received(@cart)
159
159
  redirect_to plugins_ecommerce_orders_url
@@ -80,14 +80,19 @@ module Plugins::Ecommerce::EcommerceFunctionsHelper
80
80
  hooks_run('ecommerce_calculate_exchange', args) # permit to use custom exchange app by setting the value in :exchange attribute
81
81
  return (args[:exchange] * amount).round(2) if args[:exchange].present?
82
82
 
83
- # request to google's finance converter site
84
- res = open("https://www.google.com/finance/converter?a=1&from=#{args[:from]}&to=#{args[:to]}").read
85
- res = res.scan(/\<span class=bld\>(.+?)\<\/span\>/).first.first.split(' ') # => ["69.3000", "BOB"]
86
- exchange = res.first.to_f.round(4)
83
+ exchange = e_finance_exchange_converter(args)
87
84
  cama_ecommerce_post_type.set_option(e_current_visitor_currency, {date: Date.today.to_s, exchange: exchange, base: e_system_currency}, 'currencies')
88
85
  (exchange * amount).round(2)
89
86
  end
90
87
 
88
+ # helper to calculate exchanges
89
+ def e_finance_exchange_converter(args)
90
+ # request to google's finance converter site
91
+ res = open("https://finance.google.com/finance/converter?a=1&from=#{args[:from]}&to=#{args[:to]}").read
92
+ res = res.scan(/\<span class=bld\>(.+?)\<\/span\>/).first.first.split(' ') # => ["69.3000", "BOB"]
93
+ res.first.to_f.round(4)
94
+ end
95
+
91
96
  # return all currencies to use as a base currency
92
97
  def e_get_all_currencies
93
98
  @_cache_e_get_all_currencies ||= lambda{
@@ -1,4 +1,4 @@
1
- class AddCamaEcommerceStructurePlugin < ActiveRecord::Migration
1
+ class AddCamaEcommerceStructurePlugin < CamaManager.migration_class
2
2
  def change
3
3
  unless table_exists? 'plugins_order_details'
4
4
  create_table :plugins_order_details do |t|
@@ -1,4 +1,4 @@
1
- class MoveFeaturedAttributeOfProducts < ActiveRecord::Migration
1
+ class MoveFeaturedAttributeOfProducts < CamaManager.migration_class
2
2
  def change
3
3
  Cama::Site.all.each do |site|
4
4
  ptype = site.post_types.where(slug: 'commerce').first
@@ -1,4 +1,4 @@
1
- class AddNewCartStructure < ActiveRecord::Migration
1
+ class AddNewCartStructure < CamaManager.migration_class
2
2
  def change
3
3
  create_table :plugins_ecommerce_orders do |t|
4
4
  t.string :name, :slug, :kind, :coupon, :the_coupon_amount
@@ -1,4 +1,4 @@
1
- class AddProductAttributesStructure < ActiveRecord::Migration
1
+ class AddProductAttributesStructure < CamaManager.migration_class
2
2
  def change
3
3
  create_table :plugins_ecommerce_attributes do |t|
4
4
  t.string :key, :label
@@ -1,4 +1,4 @@
1
- class SetCamaPostDecoratorClass < ActiveRecord::Migration
1
+ class SetCamaPostDecoratorClass < CamaManager.migration_class
2
2
  def change
3
3
  CamaleonCms::Site.reset_column_information
4
4
  CamaleonCms::PostType.reset_column_information
@@ -1,4 +1,4 @@
1
- class MigrateOrderData < ActiveRecord::Migration
1
+ class MigrateOrderData < CamaManager.migration_class
2
2
  def change
3
3
  if table_exists?('plugins_order_details') && Plugins::Ecommerce::LegacyOrder.count > 0
4
4
  Plugins::Ecommerce::LegacyOrder.reset_column_information
@@ -1,4 +1,4 @@
1
- class AddCookieKeyToCart < ActiveRecord::Migration
1
+ class AddCookieKeyToCart < CamaManager.migration_class
2
2
  def change
3
3
  add_column :plugins_ecommerce_orders, :visitor_key, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddInvoiceNumber < ActiveRecord::Migration
1
+ class AddInvoiceNumber < CamaManager.migration_class
2
2
  def change
3
3
  add_column :plugins_ecommerce_orders, :invoice_number, :string, default: ''
4
4
  add_column :plugins_ecommerce_orders, :invoice_path, :string, default: ''
@@ -1,4 +1,4 @@
1
- class RemoveEcommerceStockField < ActiveRecord::Migration
1
+ class RemoveEcommerceStockField < CamaManager.migration_class
2
2
  def change
3
3
  Cama::PostType.where(slug: 'commerce').each do |pt|
4
4
  pt.get_field_object('ecommerce_stock').try(:destroy)
@@ -1,3 +1,3 @@
1
1
  module Ecommerce
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_ecommerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: camaleon_cms