Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Store dicts in cart

Artur Smęt8ec2da65323c
diff --git a/saleor/product/models/variants.py b/saleor/product/models/variants.py
index 53dd149d54..2ba2e00405 100644
--- a/saleor/product/models/variants.py
+++ b/saleor/product/models/variants.py
@@ -91,4 +91,12 @@ class ProductVariant(models.Model, Item):
slug = self.product.get_slug()
product_id = self.product.id
return reverse(
- 'product:details', kwargs={'slug': slug, 'product_id': product_id})
\ No newline at end of file
+ 'product:details', kwargs={'slug': slug, 'product_id': product_id})
+
+ def as_data(self):
+ return {
+ 'product_name': str(self),
+ 'product_id': self.product.pk,
+ 'variant_id': self.pk,
+ 'unit_price': str(self.get_price_per_item().gross)
+ }
\ No newline at end of file