menu

Elastic Path

This is a community forum for discussion and knowledge sharing. For support requests, please visit support.elasticpath.com

Channels
Team

Flows changes - Carts, Orders and Bug Crushing

June 11, 2019 at 1:48pm

Flows changes - Carts, Orders and Bug Crushing

June 11, 2019 at 1:48pm (Edited 2 years ago)
We've been working hard recently to improve the developer experience when using moltin to build an online store. An important part of this is to look at how we can make working with custom flow data even easier. We're very excited to talk about some of the updates we're ready to ship!

Better flows functionality on carts & orders

One of the most reported issues with flows was that the behaviour of flow fields on items in carts was unpredictable. We've shored this up so whether you're doing a GET, PUT or POST with any type of item in your cart, flow fields are attached to the correct objects.
You can also now attach flow data to carts & objects more easily. While previously most of our users would add an item to a cart, then do a second request to add custom data, this can now be achieved in a single request, just pass the flow data with the add to cart request:
{
"data": {
"id": "31022408-f2cb-4b58-b6d7-2729bbb2c80d",
"type": "cart_item",
"quantity": 1,
"custom-field": "Some custom field!"
}
}
This also works when checking a cart out. You can pass any custom data that should be attached to the order:
{
"data": {
"shipping_address": {
"company_name": "Moltin",
"first_name": "Ron",
"last_name": "Swanson",
"line_1": "Second Floor, British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"county": "Tyne and Wear",
"postcode": "NE1 6UF",
"country": "GB",
"phone_number": "330-957-9332",
"instructions": "Leave in porch"
},
"customer": {
"name": "Ron Swanson",
"email": "[email protected]"
},
"billing_address": {
"company_name": "Moltin",
"first_name": "Jack",
"last_name": "Macdowall",
"line_1": "Second Floor, British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"county": "Tyne and Wear",
"postcode": "NE1 6UF",
"country": "GB"
},
"custom-order-field": "Super slick!"
}
}

Improved behaviour when creating/updating an entity with flow fields

  • In some instances when updating a core entity with flow fields that have validation rules. It was possible that the core entity would be updated and the flows validation would fail. In this situation, the user would get a 200 response and have no idea their flows fields were not updated. We've modified this behaviour to return the error response code and validation error message.
  • When responding to PUT/POST requests that included flow data, the values from the original client request were attached to the response, rather than the data returned from the flows service. This meant that there could sometimes be slight differences in how the data was formatted. Coupled with the issue above, it could also mean that it looked like flow data had been saved when it hadn't been saved because of a validation error.

Improved performance

  • We've streamlined the process for updating a flow, meaning all PUT/POST requests for entities that use flow fields will see a performance boost.
  • We've made some changes that will allow us to tweak how flows requests work even more so that there is scope to improve performance again in the future.

August 20, 2019 at 6:38am
Has this capability been added into the Moltin SDKs?
I'm not even seeing the ability to set/update flow data in the PHP SDK at all.
Are people just not using the SDKs?
  • reply
  • like
Hi we're not actively maintaining the PHP SDK. Feel free to submit a PR or I can add you as a maintainer. 🤩
  • reply
  • like

September 7, 2019 at 11:39am
Hey guys,
I have some custom data fields attached to Cart Items. When executing a Checkout, I'd like the custom data to go across to the Order Items also, which has the same custom data fields configured.
Is there any way to do this? I'd imagine its a pretty popular requirement, its only natural that most custom data attached to a Cart Item is probably relevant for the Order Item when the Cart is checked out.
It doesn't seem like there's opportunity to do this as part of checking out. I know individual requests could be made to update the Order Item, but this doesn't seem very efficient. Being in Australia, it takes about 2 seconds per request, so minimising the number of requests is really important.
Cheers
Edited
  • reply
  • like