Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shopping cart working #42

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@
<li class="hover:underline text-[#f4e721] underline-offset-8 hover:text-[#f4e721]">
<%= link_to "OUR CLUB", club_index_path %>
</li>
<li class="hover:underline text-[#f4e721] underline-offset-8 hover:text-[#f4e721]">
<%= link_to "SHOP", shop_index_path %>
</li>
<li class="hover:underline text-[#f4e721] underline-offset-8 hover:text-[#f4e721] ">
<%= link_to "SHOP/PRODUCT", product_index_path %>
<%= link_to "SHOP", product_index_path %>
</li>


Expand Down
14 changes: 7 additions & 7 deletions app/views/product/_production.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
<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 %>
<td><%= link_to 'Edit', edit_product_path(product), class: "bg-[#FAE115] p-3 rounded-lg mt-2" %></td>
<td><%= link_to 'Destroy', product, class: "bg-[#FAE115] p-3 rounded-lg mt-2", method: :delete, data: { confirm: 'Are you sure?' } %></td>
<%= 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" %>
<% end %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/product/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="p-6 bg-[#FAE115] font-bold uppercase text-5xl flex justify-between">
PRODUCT
SHOP

<%= render partial: "cart/cart" if @render_cart %>

Expand Down
1 change: 1 addition & 0 deletions app/views/product/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<%= image_tag(@product.photo_product) %>
<%= @product.price %>
</div>
<%= button_to "Destroy this product", @product, method: :delete %>


</div>
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.