Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Orders API - Adding Shipping Line Discounts

Orders API - Adding Shipping Line Discounts

revesderecho
New Member
7 0 0

Hello all.

 

I'm using the Shopify Orders API to create an order, that should have free shipping. try to use the discount code with type = "shipping". 

 

How can I apply the free shipping discount?

 

 

{
  "order": {
    "billing_address": {
      "address1": "Alcalde Pedro Alarcon 900",
      "address2": "Dpto 309",
      "city": "San Miguel",
      "country": "Chile",
      "first_name": "Cristian",
      "last_name": "Da Silva",
      "phone": "971906072",
      "province": ""
    },
    "carrier_id": 59350974616,
    "carrier_name": "HC Group",
    "carrier_shipping_amount": 0,
    "customer": {
      "id": "5821838065816"
    },
    "discount_codes": [
      {
        "amount": 100,
        "code": "ENVÍO GRATIS",
        "type": "shipping"
      }
    ],
    "financial_status": "paid",
    "gift_cards": [],
    "line_items": [
      {
        "quantity": 1,
        "variant_id": 41398165373080
      }
    ],
    "requires_shipping": true,
    "shipping_address": {
      "address1": "Alcalde Pedro Alarcon 900",
      "address2": "Dpto 309",
      "city": "San Miguel",
      "country": "Chile",
      "first_name": "Cristian",
      "last_name": "Da Silva",
      "phone": "971906072",
      "province": ""
    },
    "shipping_lines": [
      {
        "carrier_identifier": "9cbc654990e66235ecb3c88017d8e63e",
        "code": "hc",
        "id": 59350974616,
        "price": "2975",
        "title": "HC Group"
      }
    ],
    "transactions": [
      {
        "amount": 1890,
        "gateway": "mercadoPago",
        "installments": 1,
        "kind": "sale",
        "payment_method_id": "mercadoPago",
        "status": "success"
      }
    ]
  }
}

 

 

The result when going through checkout:

 

 

 {
  "order": {
    "admin_graphql_api_id": "gid://shopify/Order/4298209722520",
    "app_id": 5705789,
    "billing_address": {
      "address1": "Alcalde Pedro Alarcon 900",
      "address2": "Dpto 309",
      "city": "San Miguel",
      "company": null,
      "country": "Chile",
      "country_code": "CL",
      "first_name": "Cristian",
      "last_name": "Da Silva",
      "latitude": -33.4871902,
      "longitude": -70.646751,
      "name": "Cristian Da Silva",
      "phone": "971906072",
      "province": "",
      "province_code": null,
      "zip": null
    },
    "browser_ip": null,
    "buyer_accepts_marketing": false,
    "cancel_reason": null,
    "cancelled_at": null,
    "cart_token": null,
    "checkout_id": null,
    "checkout_token": null,
    "closed_at": null,
    "confirmed": true,
    "contact_email": "wolcutor@gmail.com",
    "created_at": "2022-03-28T17:43:27-04:00",
    "currency": "CLP",
    "current_subtotal_price": "1890",
    "current_subtotal_price_set": {
      "presentment_money": {
        "amount": "1890",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "1890",
        "currency_code": "CLP"
      }
    },
    "current_total_discounts": "0",
    "current_total_discounts_set": {
      "presentment_money": {
        "amount": "0",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "0",
        "currency_code": "CLP"
      }
    },
    "current_total_duties_set": null,
    "current_total_price": "4865",
    "current_total_price_set": {
      "presentment_money": {
        "amount": "4865",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "4865",
        "currency_code": "CLP"
      }
    },
    "current_total_tax": "0",
    "current_total_tax_set": {
      "presentment_money": {
        "amount": "0",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "0",
        "currency_code": "CLP"
      }
    },
    "customer": {
      "accepts_marketing": false,
      "accepts_marketing_updated_at": "2022-01-25T10:03:09-05:00",
      "admin_graphql_api_id": "gid://shopify/Customer/5821838065816",
      "created_at": "2021-12-21T09:32:27-05:00",
      "currency": "CLP",
      "default_address": {
        "address1": "Alcalde Pedro Alarcon 900",
        "address2": "Dpto 309",
        "city": "San Miguel",
        "company": null,
        "country": "Chile",
        "country_code": "CL",
        "country_name": "Chile",
        "customer_id": 5821838065816,
        "default": true,
        "first_name": "Cristian",
        "id": 7066366738584,
        "last_name": "Da Silva",
        "name": "Cristian Da Silva",
        "phone": "971906072",
        "province": "",
        "province_code": null,
        "zip": null
      },
      "email": "wolcutor@gmail.com",
      "first_name": "Cristian",
      "id": 5821838065816,
      "last_name": "Da Silva",
      "last_order_id": 4298209722520,
      "last_order_name": "#1146T",
      "marketing_opt_in_level": null,
      "multipass_identifier": null,
      "note": null,
      "orders_count": 63,
      "phone": null,
      "sms_marketing_consent": null,
      "state": "enabled",
      "tags": "BORRARCLIENTE",
      "tax_exempt": false,
      "tax_exemptions": [],
      "total_spent": "772633.00",
      "updated_at": "2022-03-28T17:43:28-04:00",
      "verified_email": true
    },
    "customer_locale": null,
    "device_id": null,
    "discount_applications": [],
    "discount_codes": [],
    "email": "wolcutor@gmail.com",
    "estimated_taxes": false,
    "financial_status": "paid",
    "fulfillment_status": null,
    "fulfillments": [],
    "gateway": "mercadoPago",
    "id": 4298209722520,
    "landing_site": null,
    "landing_site_ref": null,
    "line_items": [
      {
        "admin_graphql_api_id": "gid://shopify/LineItem/10858601054360",
        "discount_allocations": [],
        "duties": [],
        "fulfillable_quantity": 1,
        "fulfillment_service": "manual",
        "fulfillment_status": null,
        "gift_card": false,
        "grams": 100,
        "id": 10858601054360,
        "name": "FIT - fit - Celeste - 0081",
        "price": "1890",
        "price_set": {
          "presentment_money": {
            "amount": "1890",
            "currency_code": "CLP"
          },
          "shop_money": {
            "amount": "1890",
            "currency_code": "CLP"
          }
        },
        "product_exists": true,
        "product_id": 7150550745240,
        "properties": [],
        "quantity": 1,
        "requires_shipping": true,
        "sku": "A000000328",
        "tax_lines": [],
        "taxable": true,
        "title": "FIT",
        "total_discount": "0",
        "total_discount_set": {
          "presentment_money": {
            "amount": "0",
            "currency_code": "CLP"
          },
          "shop_money": {
            "amount": "0",
            "currency_code": "CLP"
          }
        },
        "variant_id": 41398165373080,
        "variant_inventory_management": "shopify",
        "variant_title": "fit - Celeste - 0081",
        "vendor": "REVESDERECHO"
      }
    ],
    "location_id": null,
    "name": "#1146T",
    "note": null,
    "note_attributes": [],
    "number": 146,
    "order_number": 1146,
    "order_status_url": "https://revesderecho-sap-tester.myshopify.com/47093416088/orders/9d44a1c4269928f6de602484400f58bd/authenticate?key=27a5eea66c4b663f899055ac04b6a9f0",
    "original_total_duties_set": null,
    "payment_gateway_names": [
      "mercadoPago"
    ],
    "payment_terms": null,
    "phone": null,
    "presentment_currency": "CLP",
    "processed_at": "2022-03-28T17:43:27-04:00",
    "processing_method": "",
    "reference": null,
    "referring_site": null,
    "refunds": [],
    "shipping_address": {
      "address1": "Alcalde Pedro Alarcon 900",
      "address2": "Dpto 309",
      "city": "San Miguel",
      "company": null,
      "country": "Chile",
      "country_code": "CL",
      "first_name": "Cristian",
      "last_name": "Da Silva",
      "latitude": -33.4871902,
      "longitude": -70.646751,
      "name": "Cristian Da Silva",
      "phone": "971906072",
      "province": "",
      "province_code": null,
      "zip": null
    },
    "shipping_lines": [
      {
        "carrier_identifier": null,
        "code": "hc",
        "delivery_category": null,
        "discount_allocations": [],
        "discounted_price": "2975",
        "discounted_price_set": {
          "presentment_money": {
            "amount": "2975",
            "currency_code": "CLP"
          },
          "shop_money": {
            "amount": "2975",
            "currency_code": "CLP"
          }
        },
        "id": 3622885589144,
        "phone": null,
        "price": "2975",
        "price_set": {
          "presentment_money": {
            "amount": "2975",
            "currency_code": "CLP",
          },
          "shop_money": {
            "amount": "2975",
            "currency_code": "CLP"
          }
        },
        "requested_fulfillment_service_id": null,
        "source": null,
        "tax_lines": [],
        "title": "HC Group"
      }
    ],
    "source_identifier": null,
    "source_name": "5705789",
    "source_url": null,
    "subtotal_price": "1890",
    "subtotal_price_set": {
      "presentment_money": {
        "amount": "1890",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "1890",
        "currency_code": "CLP"
      }
    },
    "tags": "",
    "tax_lines": [],
    "taxes_included": false,
    "test": false,
    "token": "9d44a1c4269928f6de602484400f58bd",
    "total_discounts": "0",
    "total_discounts_set": {
      "presentment_money": {
        "amount": "0",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "0",
        "currency_code": "CLP"
      }
    },
    "total_line_items_price": "1890",
    "total_line_items_price_set": {
      "presentment_money": {
        "amount": "1890",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "1890",
        "currency_code": "CLP"
      }
    },
    "total_outstanding": "2975",
    "total_price": "4865",
    "total_price_set": {
      "presentment_money": {
        "amount": "4865",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "4865",
        "currency_code": "CLP"
      }
    },
    "total_price_usd": "6.25",
    "total_shipping_price_set": {
      "presentment_money": {
        "amount": "2975",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "2975",
        "currency_code": "CLP"
      }
    },
    "total_tax": "0",
    "total_tax_set": {
      "presentment_money": {
        "amount": "0",
        "currency_code": "CLP"
      },
      "shop_money": {
        "amount": "0",
        "currency_code": "CLP"
      }
    },
    "total_tip_received": "0",
    "total_weight": 0,
    "updated_at": "2022-03-28T17:43:27-04:00",
    "user_id": null
  }
}

 

 

 

Replies 0 (0)