Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove all delivery functionality from cart
Michał Ociepka8eb6e18a4795
diff --git a/saleor/cart/__init__.py b/saleor/cart/__init__.pyindex 215d880da4..e0a6d3ef14 100755--- a/saleor/cart/__init__.py+++ b/saleor/cart/__init__.py@@ -4,79 +4,21 @@ from django.utils.translation import pgettextfrom satchless import cartfrom satchless.item import ItemSet, ClassifyingPartitioner-from ..delivery import DummyShipping, DigitalDeliveryfrom ..product.models import DigitalShip-class BaseGroup(list, ItemSet):- '''- Base Saleor cart group. It is used in cart and checkout to group products- depends on delivery methods.- '''- delivery_method = None-- def __init__(self, items, delivery_method=None):- super(BaseGroup, self).__init__(items)- if delivery_method and delivery_method not in self.delivery_method():- raise AttributeError('Bad delivery method')- self.delivery_method = delivery_method-- def get_delivery_methods(self, **kwargs):- '''- Method should returns iterable object with delivery groups.- '''- raise NotImplementedError()-- def _get_cheapest_delivery_method(self, **kwargs):- if self.delivery_method:- return (self.delivery_method,- self.delivery_method.get_price_per_item(**kwargs))- methods = self.get_delivery_methods()- prices = ((method.get_price_per_item(**kwargs), method)- for method in methods)- cheapest_price, cheapest_method = min(prices)- return cheapest_method, cheapest_price-- def get_delivery_total(self, **kwargs):- '''- Method returns price from the self.delivery_method or lowest price- from delivery methods.- '''- method, price = self._get_cheapest_delivery_method(**kwargs)- return price-- def get_delivery_method(self, **kwargs):- '''- Method returns price from the self.delivery_method or lowest price- from delivery methods.- '''- method, price = self._get_cheapest_delivery_method(**kwargs)- return method-- def get_total_with_delivery(self, **kwargs):- return self.get_total() + self.get_delivery_total()---class ShippedGroup(BaseGroup):+class ShippedGroup(list, ItemSet):'''Group for shippable products.'''- def get_delivery_methods(self):- '''- Returns shippable delivery methods.- '''- yield DummyShipping(self)+ pass-class DigitalGroup(BaseGroup):+class DigitalGroup(list, ItemSet):'''Group for digital products.'''- def get_delivery_methods(self, **kwargs):- '''- Returns digital delivery methods.- '''- yield DigitalDelivery(self)+ passclass CartPartitioner(ClassifyingPartitioner):@@ -93,21 +35,6 @@ class CartPartitioner(ClassifyingPartitioner):return DigitalGroup(items)return ShippedGroup(items)- def get_delivery_subtotal(self, partion, **kwargs):- return partion.get_delivery_total(**kwargs)-- def get_delivery_total(self, **kwargs):- items = [self.get_delivery_subtotal(partion, **kwargs)- for partion in self]- if not items:- raise AttributeError(- 'Calling get_delivery_total() for an empty cart')- return sum(items[1:], items[0])-- def get_total(self):- total = super(CartPartitioner, self).get_total()- return total + self.get_delivery_total()-class Cart(cart.Cart):'''@@ -120,6 +47,3 @@ class Cart(cart.Cart):def __unicode__(self):return pgettext('Shopping cart', 'Your cart (%(cart_count)s)') % {'cart_count': self.count()}-- def clear(self):- self._state = []diff --git a/saleor/cart/templates/cart/index.html b/saleor/cart/templates/cart/index.htmlindex 6b7ec2181c..933ffbb4cd 100644--- a/saleor/cart/templates/cart/index.html+++ b/saleor/cart/templates/cart/index.html@@ -25,12 +25,6 @@</tr></thead><tfoot>- <tr>- <td class="col-sm-4">{% trans "Shipping" %}</td>- <td class="col-sm-2"></td>- <td class="col-sm-2"></td>- <td class="col-sm-2">{% gross cart.get_delivery_total %}</td>- </tr><tr><td class="col-sm-4"></td><td class="col-sm-2">@@ -55,7 +49,7 @@</table><div class="form-group"><div>- <a href="{% url "checkout:index" %}" class="btn btn-primary">Checkout</a>+ <a href="{% url "checkout:index" %}" class="btn btn-primary">Checkout</a></div></div></form>