SUITE
This commit is contained in:
parent
c87d5445a4
commit
853ade84ae
@ -6,20 +6,28 @@ class Public::ProductOrderProductsController < ApplicationController
|
||||
#clear params
|
||||
params[:product_order_product][:product_size_id] = nil if params[:product_order_product][:product_size_id] == ""
|
||||
params[:product_order_product][:product_option_id] = nil if params[:product_order_product][:product_option_id] == ""
|
||||
|
||||
@product = Product.find(params[:product_order_product][:product_id])
|
||||
# Trying to retreive an existing pop in the current cart
|
||||
existing_product_order_product = @product_order.product_order_products.where(:product_id => params[:product_order_product][:product_id], :product_size_id => params[:product_order_product][:product_size_id], :product_option_id => params[:product_order_product][:product_option_id]).first
|
||||
|
||||
# if the pop exists in the current cart, just increase the quantity
|
||||
if existing_product_order_product
|
||||
if [1,2].include?(@product.id)
|
||||
existing_product_order_product.qty += 10
|
||||
else
|
||||
existing_product_order_product.qty += 1
|
||||
end
|
||||
existing_product_order_product.verify_qty
|
||||
existing_product_order_product.save
|
||||
else
|
||||
|
||||
@product_order_product = ProductOrderProduct.new(params.require(:product_order_product).permit(:product_id, :product_size_id, :product_option_id))
|
||||
|
||||
if [1,2].include?(@product.id)
|
||||
@product_order_product.qty = 10
|
||||
else
|
||||
@product_order_product.qty = 1
|
||||
end
|
||||
|
||||
@product_order_product.save
|
||||
|
||||
|
@ -20,6 +20,9 @@
|
||||
-if !@recap
|
||||
.qty_form
|
||||
= form_for [:public, product_order_product] do |f|
|
||||
-if [1,2].include?(product_order_product.product_id)
|
||||
= f.select :qty, [10,20,30,40,50,60,70,80,90,100], {:style => "width:30px;"}
|
||||
-else
|
||||
= f.text_field :qty, :style => "width:30px;"
|
||||
= f.submit "Mettre à jour"
|
||||
=link_to ic(:"trash-o"), public_product_order_product_path(:id => product_order_product.id, :product_order_product => {:qty => 0}), :method => :put
|
||||
|
Loading…
x
Reference in New Issue
Block a user