Draft API: Custom shipping removed when using invoice_url

Excursionist
33 0 7

Hello!  Our app creates draft orders via the Draft API, and after successfully POSTing a new draft we redirect the customer to the draft order's invoice_url as returned in the response object from Shopify.  We always load a customer account onto the draft order with their customer_id and we sometimes add a custom shipping fee as well.

 

This issue: When a customer is not logged in and is directed to the invoice_url, the custom shipping line we add is removed as well as the shipping address as set in the draft order.  These details are still in the draft order response, as well as on the draft order page in the Shopify admin however.  If we go to the draft order page in the Shopify admin and click "email invoice," if the customer clicks the link in this email our custom shipping line and pre-filled address will be on the checkout page regardless of whether the customer is logged in or not.   Why does the invoice_url behave differently than the email link?

 

Is this expected behavior?  Is there a way to get the invoice_url to behave like the link in the invoice email so that non-logged in customers can still keep the custom shipping fee we set?  We have had a few merchants complain about this as it ends up costing them money when our custom shipping fee is ignored and a lower rate is applied.

 

(note: A customer can visit the invoice_url without being logged in if, for example, they visit the invoice_url while logged in, don't finish checkout, keep the tab open, and come back later after their Shopify login cookie has expired).

 

Please advise, thanks!

 

 

 

 

0 Likes
Shopify Partner
1043 112 165

Looks like the data saved as part of the draft order are "incomplete" and cannot be pre-populated for non-logged in users. Would you mind sharing an example of payload you are sending to the Rest API? Maybe for a test draft order.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Excursionist
33 0 7

Hi @Visely-Team, thanks for the reply.  I'm just doing a standard POST request as per the Draft API specifications.  Here is an example payload (left out the line items to keep things short):

 

{
  draft_order: {
    line_items: [ [Object] ],
    note: 'Test order',
    customer: { id: '1585780785209' },
    shipping_address: {
      address1: '123 Main St',
      address2: '',
      city: 'Louisville',
      company: 'My Company',
      country: 'United States',
      first_name: 'Matt',
      last_name: 'Test',
      province: 'Kentucky',
      zip: '40205'
    },
    shipping_line: {
      custom: 'true',
      handle: '',
      price: '1.11',
      title: 'Custom Shipping Fee'
    }
  }
}
0 Likes
Shopify Partner
1043 112 165

Hey @Matt_Goodwin , try adding  "country_code" and "province_code" to the "shipping_address" object, in your case that would change to:

{
  draft_order: {
    line_items: [ [Object] ],
    note: 'Test order',
    customer: { id: '1585780785209' },
    shipping_address: {
      address1: '123 Main St',
      address2: '',
      city: 'Louisville',
      company: 'My Company',
      country: 'United States',
      country_code: 'US',
      first_name: 'Matt',
      last_name: 'Test',
      province: 'Kentucky',
      province_code: 'KY',
      zip: '40205'
    },
    shipping_line: {
      custom: 'true',
      handle: '',
      price: '1.11',
      title: 'Custom Shipping Fee'
    }
  }
}
Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes