Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Cosmetics
Patryk Zawadzki0f007d4067e3
diff --git a/saleor/cart/__init__.py b/saleor/cart/__init__.pyindex 840f8b3e15..9f576479c5 100755--- a/saleor/cart/__init__.py+++ b/saleor/cart/__init__.py@@ -1,23 +1,21 @@from __future__ import unicode_literalsfrom django.conf import settings-from django.utils.translation import pgettextfrom django.utils.encoding import python_2_unicode_compatible+from django.utils.translation import pgettextfrom prices import Pricefrom satchless import cartfrom satchless.item import ItemList, partition-CART_SESSION_KEY = 'cart'-class ProductGroup(ItemList):+class ProductGroup(ItemList):def is_shipping_required(self):return any(p.is_shipping_required() for p in self)class CartLine(cart.CartLine):-def __init__(self, product, quantity, data=None, discounts=None):super(CartLine, self).__init__(product, quantity, data=data)self.discounts = discounts@@ -32,10 +30,11 @@ class CartLine(cart.CartLine):@python_2_unicode_compatibleclass Cart(cart.Cart):- '''- Contains cart items. Serialized instance of cart is saved into django- session.- '''+ """Full-fledged cart implementation++ This implementation depends on the database to implement its functionality.+ A lightweight SessionCart is kept internally for easy storage.+ """timestamp = Nonebilling_address = None@@ -65,7 +64,8 @@ class Cart(cart.Cart):# TODO: Provide error messagecontinueelse:- variant = product.variants.get_subclass(pk=item.data['variant_id'])+ variant = product.variants.get_subclass(+ pk=item.data['variant_id'])quantity = item.quantitycart.add(variant, quantity=quantity, check_quantity=False,skip_session_cart=True)@@ -101,12 +101,12 @@ class Cart(cart.Cart):def partition(self):return partition(- self, lambda p: 'physical' if p.is_shipping_required() else 'digital',+ self,+ lambda p: 'physical' if p.is_shipping_required() else 'digital',ProductGroup)class SessionCartLine(cart.CartLine):-def get_price_per_item(self, **kwargs):gross = self.data['unit_price_gross']net = self.data['unit_price_net']@@ -129,13 +129,13 @@ class SessionCartLine(cart.CartLine):@python_2_unicode_compatibleclass SessionCart(cart.Cart):- '''Simplified cart representation that gets serialized into the user's session.+ """Simplified cart representation that gets serialized into the user's session.It contains just enough information to display cart contents on every pagewithout executing any database queries. At times it may be inaccurate ifprices or item availability change but it should not matter as checkoutdepends on the full representation of the cart.- '''+ """def __str__(self):return 'SessionCart'