off recaptcha added number order
This commit is contained in:
parent
3d73563512
commit
3b72b3a113
2
Gemfile
2
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'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% content_for :header_scripts do %>
|
||||
<% if @ss.recaptcha_chk.eql?(true) %>
|
||||
<% content_for :header_scripts do %>
|
||||
<script src='https://www.google.com/recaptcha/api.js?onload=onRecaptchaElementLoad&render=explicit' async="async" defer="defer"></script>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
|
|
@ -84,7 +86,9 @@
|
|||
</div>
|
||||
<!-- end row -->
|
||||
<%= 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');
|
||||
|
|
|
|||
|
|
@ -40,10 +40,12 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<% if @ss.recaptcha_chk.eql?(true) %>
|
||||
<h5 class="thin subtitle">Potwierdź, że nie jesteś robotem</h5>
|
||||
<div class="form-group">
|
||||
<div id="recaptcha"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-group">
|
||||
<%= raw submit_tag(raw('Potwierdzam zamówienie'), class: "btn btn-default btn-md round pull-right") %>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue