diff options
author | Matthew Lemon <y@yulqen.org> | 2024-10-20 16:42:21 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-10-20 16:42:21 +0100 |
commit | fce28f5be8ba8831eed5ccf482fa2abf5432ee89 (patch) | |
tree | 3f0260c44accb04fa46f1e493bed466fff31c871 /alphabetlearning/templates/resources | |
parent | 791cf758caaf25a9375005bdd7f699e614729823 (diff) |
Cart shows items in it; disables buttons if item in basket
- Rough cart icon in navbar
- Shows items in cart
- Styled dependent on existence
- Add to cart buttons disabled if resource in cart, on resource list
page and detail page
- Throws 404 error if trying add item to cart which has no price -
eventually all items will have a price
Diffstat (limited to 'alphabetlearning/templates/resources')
3 files changed, 39 insertions, 13 deletions
diff --git a/alphabetlearning/templates/resources/resource_card_featured.html b/alphabetlearning/templates/resources/resource_card_featured.html index c83ac0f..0782b0c 100644 --- a/alphabetlearning/templates/resources/resource_card_featured.html +++ b/alphabetlearning/templates/resources/resource_card_featured.html @@ -32,10 +32,17 @@ {% endif %} <div class="d-flex flex-row justify-content-between align-items-end mt-2"> <p class="card-text m-1"><small class="text-muted">1 credit</small></p> - <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> - {% csrf_token %} - <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> - </form> + {% if resource.in_cart %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0" disabled>In basket</button> + </form> + {% else %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> + </form> + {% endif %} </div> </div> diff --git a/alphabetlearning/templates/resources/resource_card_standard.html b/alphabetlearning/templates/resources/resource_card_standard.html index 9850117..640f75d 100644 --- a/alphabetlearning/templates/resources/resource_card_standard.html +++ b/alphabetlearning/templates/resources/resource_card_standard.html @@ -37,10 +37,20 @@ </div> <div class="d-flex flex-row justify-content-between align-items-end mt-2"> <p class="card-text m-1"><small class="text-muted">1 credit</small></p> - <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> - {% csrf_token %} - <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> - </form> + + {% if resource.in_cart %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0" disabled>In basket</button> + </form> + {% else %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> + </form> + {% endif %} + + </div> </div> </div> diff --git a/alphabetlearning/templates/resources/resource_detail.html b/alphabetlearning/templates/resources/resource_detail.html index 6c6ceda..b92ba52 100644 --- a/alphabetlearning/templates/resources/resource_detail.html +++ b/alphabetlearning/templates/resources/resource_detail.html @@ -48,11 +48,20 @@ </div> <div class="row align-items-end"> <div class="my-4 d-flex justify-content-center"> - <form action="{% url 'payments:add_to_cart' resource.id %}" method="get" accept-charset="utf-8"> - <button class="btn btn-primary w-100"> - Add to cart - </button> - </form> + {% if resource.in_cart %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="get" accept-charset="utf-8"> + <button class="btn btn-primary w-100" disabled> + In basket + </button> + </form> + {% else %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="get" accept-charset="utf-8"> + <button class="btn btn-primary w-100"> + Add to basket + </button> + </form> + + {% endif %} </div> </div> </div> |