Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Revert "Remove unused methods"
Artur Smęt6a322fd8ae73
diff --git a/saleor/cart/__init__.py b/saleor/cart/__init__.pyindex 134006a6c6..7ca0642a50 100755--- a/saleor/cart/__init__.py+++ b/saleor/cart/__init__.py@@ -61,6 +61,8 @@ class Cart(cart.Cart):class SessionCart(cart.Cart):'''Serializable representation of cart.+ Parameters:+ variant - Instance of ProductVariant'''def __str__(self):@@ -98,3 +100,10 @@ class SessionCart(cart.Cart):def count(self):return sum([item['quantity'] for item in self._state])++ def for_storage(self):+ cart_data = {+ 'items': self._state,+ 'modified': self.modified+ }+ return cart_data\ No newline at end of filediff --git a/saleor/cart/tests.py b/saleor/cart/tests.pyindex e336f49868..d12f3e8f28 100755--- a/saleor/cart/tests.py+++ b/saleor/cart/tests.py@@ -182,3 +182,11 @@ class SessionCartTest(TestCase):def test_count(self):self.cart.add(stock_product, quantity=5)self.assertEqual(self.cart.count(), 5)++ def test_as_data(self):+ self.cart.add(stock_product, quantity=5)+ expected = {+ 'items': self.cart._state,+ 'modified': True+ }+ self.assertEqual(self.cart.for_storage(), expected)\ No newline at end of filediff --git a/saleor/product/models/variants.py b/saleor/product/models/variants.pyindex 300cd45181..2ba2e00405 100644--- a/saleor/product/models/variants.py+++ b/saleor/product/models/variants.py@@ -99,4 +99,4 @@ class ProductVariant(models.Model, Item):'product_id': self.product.pk,'variant_id': self.pk,'unit_price': str(self.get_price_per_item().gross)- }+ }\ No newline at end of file