Skip to content

Commit

Permalink
shopping cart working
Browse files Browse the repository at this point in the history
  • Loading branch information
ger619 committed Jul 10, 2023
1 parent 36c7953 commit 988eb25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/views/product/_production.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
<h1 class="text-2xl md:text-5xl font-bold uppercase"><%= product.description %></h1>

<p class="mt-2"><%= product.name %>Color: Yellow with Black and White stripes</p>
<div class="mt-2 gap-3 grid grid-cols-4">
<p class="border-[#FAE115] border-2 p-2 md:p-4 size-option uppercase" data-size="Small"><%= product.size %></p>
</div>

<div id="price" class="mt-2 mb-2">Price: <%= product.price %></div>

<div id="price" class="mt-2">Price: <%= product.price %></div>
<%= form_with(url: cart_add_path) do |f| %>
<%= f.hidden_field :product_id, value: product.id %>
<%= f.select :size, ['SMALL', 'MEDIUM', 'LARGE'], prompt: 'Size of The Shirt', class: "border-[#FAE115] border-2 p-2 md:p-4 size-option uppercase" %>
<br/><br/>
<%= f.number_field :quantity, value: 1, min: 1, id: "quantity", class: "bg-[#FAE115] border-none" %>
<br/>
<%= f.submit "Add to cart", class: "bg-[#FAE115] p-3 rounded-lg mt-2" %>
<% end %>
<br/>

<button id="buyButton" class="bg-[#FAE115] p-3 rounded-lg mt-2">Buy Now</button>
<% if current_user %>
<%= link_to 'Edit', edit_product_path(product), class: "bg-[#FAE115] p-3 rounded-lg mt-2" %>
<%= link_to 'Destroy', @product, method: :delete, data: { confirm: 'Are you sure?' }, class: "bg-[#FAE115] p-3 rounded-lg mt-2" %>
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20230708163512_create_orderables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def change
create_table :orderables do |t|
t.belongs_to :product, null: false, foreign_key: true
t.belongs_to :cart, null: false, foreign_key: true
t.string :size
t.integer :quantity

t.timestamps
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 988eb25

Please sign in to comment.