diff --git a/app/controllers/product_cart_controller.rb b/app/controllers/product_cart_controller.rb index d552c22..87760a2 100644 --- a/app/controllers/product_cart_controller.rb +++ b/app/controllers/product_cart_controller.rb @@ -16,7 +16,9 @@ def show def remove item = @cart.product_cart_items.find_by(product_id: params[:product_id]) item.destroy if item - redirect_to( product_cart_path, notice: 'Item removed from cart') + @cart_items = @cart.product_cart_items.includes(:product) + render "destroy" + # redirect_to( product_cart_path, notice: 'Item removed from cart') end private diff --git a/app/views/product_cart/_cart.erb b/app/views/product_cart/_cart.erb new file mode 100644 index 0000000..69a081a --- /dev/null +++ b/app/views/product_cart/_cart.erb @@ -0,0 +1,29 @@ +
Quantity: <%= item.quantity %>
+Price: <%= number_to_currency(item.product.price) %>
+Total: <%= number_to_currency(@cart.total_price) %>
+ <%= form_tag product_checkout_index_path, method: :post, data: {turbo: false } do %> + <%= submit_tag "Proceed to Checkout", class: "mt-4 bg-muted text-default px-6 py-3 rounded-lg font-bold cursor-pointer" %> + <% end %> +Your cart is empty.
+ <% end %> +Quantity: <%= item.quantity %>
-Price: <%= number_to_currency(item.product.price) %>
-Total: <%= number_to_currency(@cart.total_price) %>
- <%= form_tag product_checkout_index_path, method: :post, data: {turbo: false } do %> - <%= submit_tag "Proceed to Checkout", class: "mt-4 bg-muted text-default px-6 py-3 rounded-lg font-bold cursor-pointer" %> - <% end %> -Your cart is empty.
- <% end %> +