Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add product name to gift line. (#15987)
Piotr Zabieglikf8a4c5f4c6e9
diff --git a/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_order.py b/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_order.pyindex 86a3a48bdb..ff6ddc0f3a 100644--- a/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_order.py+++ b/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_order.py@@ -219,6 +219,7 @@ def test_create_order_discount_gift(# givenorder = order_with_linesvariant = variant_with_many_stocks+ product = variant.productchannel = order.channelpromotion = order_promotion_without_rulespromotion_id = graphene.Node.to_global_id("Promotion", promotion.id)@@ -269,6 +270,8 @@ def test_create_order_discount_gift(assert gift_line.unit_discount_amount == Decimal(0)assert gift_line.unit_discount_type == RewardValueType.FIXEDassert gift_line.unit_discount_value == Decimal(0)+ assert gift_line.product_name == product.name+ assert gift_line.product_sku == variant.skudef test_multiple_rules_subtotal_and_catalogue_discount_applied(diff --git a/saleor/discount/utils.py b/saleor/discount/utils.pyindex 309f8bbf1f..b6f8c8ccfd 100644--- a/saleor/discount/utils.py+++ b/saleor/discount/utils.py@@ -1037,8 +1037,16 @@ def _get_defaults_for_gift_line("currency": order_or_checkout.currency,}else:+ variant = (+ ProductVariant.objects.filter(id=variant_id)+ .select_related("product")+ .only("sku", "product__name")+ .first()+ )return {"variant_id": variant_id,+ "product_name": variant.product.name if variant else "",+ "product_sku": variant.sku if variant else "","quantity": 1,"currency": order_or_checkout.currency,"unit_price_net_amount": Decimal(0),