Merge branch 'release/2.0.14'
This commit is contained in:
commit
8d5f7fe6b9
@ -10,7 +10,7 @@
|
||||
{% csrf_token %}
|
||||
{{form.as_p}}
|
||||
<p class="form__submit">
|
||||
<input class="action-button" type="submit" value="Create category"> or <a href="{% url 'dashboard:category-detail' category.pk %}">cancel</a>
|
||||
<input class="action-button" type="submit" value="Save changes"> or <a href="{% url 'dashboard:category-detail' category.pk %}">cancel</a>
|
||||
</p>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<figcaption><strong>{{variant}}</strong></figcaption>
|
||||
</figure>
|
||||
<span>{{ variant.sku }}</span>
|
||||
<span>{{ variant.stock }}</span>
|
||||
<span>{{ variant.stock|default_if_none:"0" }}</span>
|
||||
<span>{{ variant.total_in_warehouse }}</span>
|
||||
<a href="{% url 'dashboard:variant-restock' product.pk variant.pk %}" class="action-button">Restock →</a>
|
||||
{% endwith %}
|
||||
|
||||
@ -10,7 +10,7 @@ from django.core.cache import cache
|
||||
from django.db.models import OuterRef, Q, Subquery
|
||||
|
||||
from core.models import (
|
||||
Product, ProductVariant, OrderLine, Coupon, ShippingRate,
|
||||
ProductCategory, Product, ProductVariant, OrderLine, Coupon, ShippingRate,
|
||||
SiteSettings
|
||||
)
|
||||
from core.usps import USPSApi
|
||||
@ -60,11 +60,11 @@ class CartItem:
|
||||
|
||||
class Cart:
|
||||
item_class = CartItem
|
||||
# site_settings = SiteSettings.load()
|
||||
|
||||
def __init__(self, request):
|
||||
self.request = request
|
||||
self.session = request.session
|
||||
self.site_settings = SiteSettings.load()
|
||||
self.coupon_code = self.session.get('coupon_code')
|
||||
cart = self.session.get(settings.CART_SESSION_ID)
|
||||
if not cart:
|
||||
@ -129,6 +129,16 @@ class Cart:
|
||||
def __len__(self):
|
||||
return sum([item['quantity'] for item in self.cart])
|
||||
|
||||
def get_item_prices_for_category(self, category):
|
||||
for item in self:
|
||||
if item['variant'].product.category == category:
|
||||
yield item['price_total']
|
||||
else:
|
||||
continue
|
||||
|
||||
def get_total_price_for_category(self, category):
|
||||
return sum(self.get_item_prices_for_category(category))
|
||||
|
||||
def get_all_item_quantities(self):
|
||||
for item in self.cart:
|
||||
yield item['quantity']
|
||||
@ -139,8 +149,6 @@ class Cart:
|
||||
def get_item_prices(self):
|
||||
for item in self:
|
||||
yield item['price_total']
|
||||
# for item in self.cart.values():
|
||||
# yield Decimal(item['price']) * sum([value['quantity'] for value in item['variations'].values()])
|
||||
|
||||
def get_total_price(self):
|
||||
return sum(self.get_item_prices())
|
||||
@ -170,9 +178,11 @@ class Cart:
|
||||
return containers
|
||||
|
||||
def get_shipping_cost(self, container=None):
|
||||
# free_shipping_min = self.site_settings.free_shipping_min
|
||||
# if self.get_total_price() >= free_shipping_min:
|
||||
# return Decimal('0.00')
|
||||
free_shipping_min = self.site_settings.free_shipping_min
|
||||
if free_shipping_min is not None:
|
||||
category = ProductCategory.objects.get(name='Coffee')
|
||||
if self.get_total_price_for_category(category) >= free_shipping_min:
|
||||
return Decimal('0.00')
|
||||
|
||||
if container is None:
|
||||
container = self.session.get('shipping_container').container
|
||||
|
||||
@ -58,7 +58,10 @@
|
||||
<input type="submit" value="Apply" class="action-button">
|
||||
</p>
|
||||
</form>
|
||||
<!-- <h5>Free shipping on orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}</h5> -->
|
||||
<h5>
|
||||
Free shipping on coffee orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}<br>
|
||||
<small><em>Merch does not count toward total</em></small>
|
||||
</h5>
|
||||
<div class="cart__table-wrapper">
|
||||
<table class="cart__totals">
|
||||
<tr>
|
||||
|
||||
@ -65,6 +65,10 @@
|
||||
{% csrf_token %}
|
||||
{{form.as_p}}
|
||||
</form>
|
||||
<h5>
|
||||
Free shipping on coffee orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}<br>
|
||||
<small><em>Merchandise does not count toward total</em></small>
|
||||
</h5>
|
||||
<div class="cart__table-wrapper">
|
||||
<table class="cart__totals">
|
||||
<tr>
|
||||
|
||||
@ -20,12 +20,12 @@ class RequestFaker:
|
||||
},
|
||||
},
|
||||
'items': [{
|
||||
'name': 'Decaf: 16 oz',
|
||||
'name': 'Decaf: 16 oz Grind: Whole Beans',
|
||||
'description': 'Medium Roast',
|
||||
'unit_amount': {'currency_code': 'USD', 'value': '13.40'},
|
||||
'quantity': '1'
|
||||
}, {
|
||||
'name': 'Decaf: 16 oz',
|
||||
'name': 'Decaf: 16 oz Grind: Percolator',
|
||||
'description': 'Medium Roast',
|
||||
'unit_amount': {'currency_code': 'USD', 'value': '13.40'},
|
||||
'quantity': '2'
|
||||
|
||||
@ -36,7 +36,7 @@ class CreateOrderTest(TestCase):
|
||||
name='16 oz',
|
||||
sku='234987',
|
||||
price=13.4,
|
||||
weight=Weight(oz=16),
|
||||
weight=Weight(oz=16)
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@ -5,7 +5,6 @@ urlpatterns = [
|
||||
path('about/', views.AboutView.as_view(), name='about'),
|
||||
path('fair-trade/', views.FairTradeView.as_view(), name='fair-trade'),
|
||||
path('reviews/', views.ReviewListView.as_view(), name='reviews'),
|
||||
path('contact/', views.ContactFormView.as_view(), name='contact'),
|
||||
path(
|
||||
'subscriptions/',
|
||||
views.SubscriptionCreateView.as_view(),
|
||||
|
||||
@ -558,17 +558,6 @@ class ReviewListView(TemplateView):
|
||||
template_name = 'storefront/reviews.html'
|
||||
|
||||
|
||||
class ContactFormView(FormView, SuccessMessageMixin):
|
||||
template_name = 'storefront/contact_form.html'
|
||||
form_class = ContactForm
|
||||
success_url = reverse_lazy('storefront:product-list')
|
||||
success_message = 'Message sent.'
|
||||
|
||||
def form_valid(self, form):
|
||||
form.send_email()
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class SubscriptionCreateView(FormView):
|
||||
template_name = 'storefront/subscriptions.html'
|
||||
form_class = SubscriptionCreateForm
|
||||
|
||||
@ -46,14 +46,9 @@
|
||||
<nav class="site__nav">
|
||||
<a class="site__logo" href="{% url 'storefront:product-list' %}"><img src="{% static 'images/site_logo.svg' %}" alt="Port Townsend Roasting Co."></a>
|
||||
<ul class="nav__list nav__main">
|
||||
<li class="nav__menu">
|
||||
<a class="nav__link" href="{% url 'storefront:product-list' %}">Shop ▼</a>
|
||||
<ul class="nav__dropdown">
|
||||
{% for category in category_list %}
|
||||
<li><a class="nav__link" href="{% url 'storefront:category-detail' category.pk %}">{{ category }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<!-- <li><a class="nav__link" href="{% url 'storefront:subscriptions' %}">Subscriptions</a></li> -->
|
||||
<li><a class="nav__link" href="{% url 'storefront:fair-trade' %}">Fair trade</a></li>
|
||||
<li><a class="nav__link" href="{% url 'storefront:reviews' %}">Reviews</a></li>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user