Add cart stock limits
This commit is contained in:
parent
6c8abec2d5
commit
0dd19b2d5b
@ -71,6 +71,14 @@ class ProductCategory(models.Model):
|
|||||||
verbose_name_plural = 'Product Categories'
|
verbose_name_plural = 'Product Categories'
|
||||||
|
|
||||||
|
|
||||||
|
class ProductManager(models.Manager):
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().prefetch_related(
|
||||||
|
'productphoto_set',
|
||||||
|
'options'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Product(models.Model):
|
class Product(models.Model):
|
||||||
category = models.ForeignKey(
|
category = models.ForeignKey(
|
||||||
ProductCategory,
|
ProductCategory,
|
||||||
@ -92,6 +100,8 @@ class Product(models.Model):
|
|||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
objects = ProductManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@ -124,6 +134,12 @@ class ProductVariant(models.Model):
|
|||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
related_name='variants'
|
related_name='variants'
|
||||||
)
|
)
|
||||||
|
image = models.ForeignKey(
|
||||||
|
'ProductPhoto',
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
related_name='+',
|
||||||
|
null=True
|
||||||
|
)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
sku = models.CharField(max_length=255, unique=True)
|
sku = models.CharField(max_length=255, unique=True)
|
||||||
stripe_id = models.CharField(max_length=255, blank=True)
|
stripe_id = models.CharField(max_length=255, blank=True)
|
||||||
@ -145,6 +161,7 @@ class ProductVariant(models.Model):
|
|||||||
null=True,
|
null=True,
|
||||||
validators=[MinValueValidator(0)]
|
validators=[MinValueValidator(0)]
|
||||||
)
|
)
|
||||||
|
sorting = models.PositiveIntegerField(blank=True, null=True)
|
||||||
|
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
@ -155,7 +172,7 @@ class ProductVariant(models.Model):
|
|||||||
return f'{self.product}: {self.name}'
|
return f'{self.product}: {self.name}'
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['weight']
|
ordering = ['sorting', 'weight']
|
||||||
|
|
||||||
|
|
||||||
class ProductOption(models.Model):
|
class ProductOption(models.Model):
|
||||||
@ -491,6 +508,13 @@ class SiteSettings(SingletonBase):
|
|||||||
related_name='+',
|
related_name='+',
|
||||||
on_delete=models.SET_NULL
|
on_delete=models.SET_NULL
|
||||||
)
|
)
|
||||||
|
free_shipping_min = models.DecimalField(
|
||||||
|
max_digits=settings.DEFAULT_MAX_DIGITS,
|
||||||
|
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
help_text='Minimum dollar amount in the cart subtotal to qualify for free shipping'
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'Site Settings'
|
return 'Site Settings'
|
||||||
|
|||||||
@ -23,5 +23,17 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="object__panel">
|
||||||
|
<div class="object__item panel__header panel__header--flex">
|
||||||
|
<h4>Site Settings</h4>
|
||||||
|
<a href="{% url 'dashboard:settings-update' site_settings.pk %}" class="action-button order__fulfill">Edit</a>
|
||||||
|
</div>
|
||||||
|
<div class="panel__item">
|
||||||
|
<p>USPS User ID: {{ site_settings.usps_user_id }}</p>
|
||||||
|
<p>Default shipping rate: {{ site_settings.default_shipping_rate }}</p>
|
||||||
|
<p>Free shipping min: ${{ site_settings.free_shipping_min }}</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</article>
|
</article>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
</figure>
|
</figure>
|
||||||
<span>{{product.sku}}</span>
|
<span>{{product.sku}}</span>
|
||||||
<span>{{item.quantity}}</span>
|
<span>{{item.quantity}}</span>
|
||||||
<span>${{item.variant.price}}</span>
|
<span>${{item.unit_price}}</span>
|
||||||
<span>${{item.get_total}}</span>
|
<span>${{item.get_total}}</span>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -12,6 +12,11 @@ urlpatterns = [
|
|||||||
views.DashboardConfigView.as_view(),
|
views.DashboardConfigView.as_view(),
|
||||||
name='config'
|
name='config'
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
'settings/<int:pk>/update/',
|
||||||
|
views.SiteSettingsUpdateView.as_view(),
|
||||||
|
name='settings-update'
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
'catalog/',
|
'catalog/',
|
||||||
views.CatalogView.as_view(),
|
views.CatalogView.as_view(),
|
||||||
|
|||||||
@ -54,6 +54,7 @@
|
|||||||
<input type="submit" value="Apply" class="action-button">
|
<input type="submit" value="Apply" class="action-button">
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
<h5>Free shipping on orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}</h5>
|
||||||
<div class="cart__table-wrapper">
|
<div class="cart__table-wrapper">
|
||||||
<table class="cart__totals">
|
<table class="cart__totals">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user