Skip to content

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

Add shipping method name to order

Anna Siwikf98547fff29a
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 94d70c166e..5b501f2fcc 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -432,9 +432,13 @@ def create_fake_order():
'shipping_address': address,
'user_email': get_email(
address.first_name, address.last_name)}
+
shipping_method = ShippingMethod.objects.order_by('?').first()
shipping_price = shipping_method.price_per_country.first().price
- order_data.update({'shipping_price': shipping_price})
+ order_data.update({
+ 'shipping_method_name': shipping_method.name,
+ 'shipping_price': shipping_price})
+
order = Order.objects.create(**order_data)
lines = create_order_lines(order, random.randrange(1, 5))
diff --git a/saleor/order/migrations/0035_auto_20180210_1359.py b/saleor/order/migrations/0035_auto_20180212_0629.py
similarity index 74%
rename from saleor/order/migrations/0035_auto_20180210_1359.py
rename to saleor/order/migrations/0035_auto_20180212_0629.py
index 715c89e2bc..be2f2180c9 100644
--- a/saleor/order/migrations/0035_auto_20180210_1359.py
+++ b/saleor/order/migrations/0035_auto_20180212_0629.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.0.2 on 2018-02-10 19:59
+# Generated by Django 2.0.2 on 2018-02-12 12:29
from django.db import migrations, models
import django.db.models.deletion
@@ -19,6 +19,11 @@ class Migration(migrations.Migration):
model_name='orderline',
name='delivery_group',
),
+ migrations.AddField(
+ model_name='order',
+ name='shipping_method_name',
+ field=models.CharField(blank=True, default=None, editable=False, max_length=255, null=True),
+ ),
migrations.AlterField(
model_name='orderline',
name='order',
diff --git a/saleor/order/models.py b/saleor/order/models.py
index e8da8ab964..d92fa1610f 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -60,6 +60,8 @@ class Order(models.Model):
default=0, editable=False)
shipping_price = TaxedMoneyField(
net_field='shipping_price_net', gross_field='shipping_price_gross')
+ shipping_method_name = models.CharField(
+ max_length=255, null=True, default=None, blank=True, editable=False)
token = models.CharField(max_length=36, unique=True)
total_net = MoneyField(
currency=settings.DEFAULT_CURRENCY, max_digits=12, decimal_places=2,