diff --git a/Gemfile b/Gemfile index f13fdd1..4c56d86 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby -gem 'bcrypt', platforms: :ruby +gem 'bcrypt', '3.1.11', platforms: :ruby gem 'breadcrumbs_on_rails' gem 'devise' gem 'paperclip' diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 79419d2..a84fb49 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -26,12 +26,15 @@ class CheckoutController < ShopController def end_order if !@cart.blank? && !@order.blank? - if RecaptchaVerifier.verify(params['g-recaptcha-response'], request.ip) + if @ss.recaptcha_chk.eql?(false) || (@ss.recaptcha_chk.eql?(true) && RecaptchaVerifier.verify(params['g-recaptcha-response'], request.ip)) if @order.update_attributes(order_params) @order.status = 1 # kopiujemy wszystkie produkty z koszyka i odejmujemy od ilosci # z rezerwacji jesli jest taka potrzeba copy_cart_prod_to_order(@cart, @order) + orders_max_number = Order.where('order_number IS NOT NULL') + .order('order_number DESC').first + @order.order_number = orders_max_number.order_number + 1 @order.save # usunac ciasteczko z koszykiem jesli wszystko sie udalo delete_cookies_for_cart diff --git a/app/models/order.rb b/app/models/order.rb index 35c34bb..4d27f7c 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -50,7 +50,11 @@ class Order < ApplicationRecord end def beauty_id - id.to_s.rjust(8, '0') + if order_number.nil? + '---------' + else + order_number.to_s.rjust(8, '0') + end end def date_checkout diff --git a/app/views/checkout/order.html.erb b/app/views/checkout/order.html.erb index a72fd65..0ea3ee5 100644 --- a/app/views/checkout/order.html.erb +++ b/app/views/checkout/order.html.erb @@ -11,8 +11,10 @@ <% else %> -<% content_for :header_scripts do %> - +<% if @ss.recaptcha_chk.eql?(true) %> + <% content_for :header_scripts do %> + + <% end %> <% end %>
@@ -84,7 +86,9 @@
<%= javascript_tag do %> +<% if @ss.recaptcha_chk.eql?(true) %> var onRecaptchaElementLoad = function() { grecaptcha.render('recaptcha', { 'sitekey' : '<%= j ENV["REACAPTCHA_SITE_KEY"]%>', 'hl': 'pl' }); }; +<% end %> $('#changetabbutton1').click(function(e){ e.preventDefault(); $('#checkout_tabs a[href="#billing-info"]').tab('show'); diff --git a/app/views/checkout/partials/_payment_methods.html.erb b/app/views/checkout/partials/_payment_methods.html.erb index a6dc1be..ed0ba61 100644 --- a/app/views/checkout/partials/_payment_methods.html.erb +++ b/app/views/checkout/partials/_payment_methods.html.erb @@ -40,10 +40,12 @@
+ <% if @ss.recaptcha_chk.eql?(true) %>
Potwierdź, że nie jesteś robotem
+ <% end %>
<%= raw submit_tag(raw('Potwierdzam zamówienie'), class: "btn btn-default btn-md round pull-right") %>