Skip to content

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

Make schema.org markup generation compatibile with Money instead of Price

Pacu2e31175f963cc
diff --git a/saleor/order/emails_helpers.py b/saleor/order/emails_helpers.py
index 3494e5dac2..dde53d6cee 100644
--- a/saleor/order/emails_helpers.py
+++ b/saleor/order/emails_helpers.py
@@ -11,7 +11,8 @@ def get_organization():
return {'@type': 'Organization', 'name': site.name}
-def get_product_data(line, currency, organization):
+def get_product_data(line, organization):
+ gross_product_price = line.get_total().gross
product_data = {
'@type': 'Offer',
'itemOffered': {
@@ -19,8 +20,8 @@ def get_product_data(line, currency, organization):
'name': line.product_name,
'sku': line.product_sku,
},
- 'price': line.get_total().gross,
- 'priceCurrency': currency,
+ 'price': gross_product_price.amount,
+ 'priceCurrency': gross_product_price.currency,
'eligibleQuantity': {
'@type': 'QuantitativeValue',
'value': line.quantity
@@ -47,8 +48,8 @@ def get_order_confirmation_markup(order):
'@type': 'Order',
'merchant': organization,
'orderNumber': order.pk,
- 'priceCurrency': order.total.currency,
- 'price': order.total.gross,
+ 'priceCurrency': order.total.gross.currency,
+ 'price': order.total.gross.amount,
'acceptedOffer': [],
'url': order_url,
'potentialAction': {
@@ -59,8 +60,6 @@ def get_order_confirmation_markup(order):
'orderDate': order.created}
for line in order.get_lines():
- product_data = get_product_data(
- line=line, currency=order.total.currency,
- organization=organization)
+ product_data = get_product_data(line=line, organization=organization)
data['acceptedOffer'].append(product_data)
return json.dumps(data, cls=DjangoJSONEncoder)
diff --git a/tests/test_emails_helpers.py b/tests/test_emails_helpers.py
index 39425342a2..78e24e4219 100644
--- a/tests/test_emails_helpers.py
+++ b/tests/test_emails_helpers.py
@@ -8,7 +8,7 @@ from saleor.order.emails_helpers import (
get_order_confirmation_markup, get_organization, get_product_data)
-def test_get_organization(site_settings):
+def test_get_organization():
example_name = 'Saleor Brand Name'
site = Site.objects.get_current()
site.name = example_name
@@ -21,10 +21,9 @@ def test_get_organization(site_settings):
def test_get_product_data_without_image(order_with_lines):
"""Tested OrderLine Product has no image assigned."""
order_line = order_with_lines.get_lines()[0]
- currency = order_with_lines.total.currency
organization = get_organization()
- result = get_product_data(order_line, currency, organization)
+ result = get_product_data(order_line, organization)
assert 'image' not in result['itemOffered']
@@ -38,7 +37,7 @@ def test_get_product_data_with_image(delivery_group, product_with_image):
currency = order.total.currency
organization = get_organization()
- result = get_product_data(order_line, currency, organization)
+ result = get_product_data(order_line, organization)
assert 'image' in result['itemOffered']
assert result['itemOffered']['name'] == product_with_image.name