You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating a custom shipping provider and I need to store a JSON value which is an array of objects in the shipping provider setting. I can get this working from the front-end, but when calculating the shipping rates it throws and JSON error. The same error happens when just adding square brackets into a normal text field setting and not even using any JSON:
If you inherit from ShippingProviderBase without using a settings class it works but if you try and use a settings class you get the error. Obviously without inheriting from the settings class you won't get the settings in the UI.
Fundamentally, shipping provider settings are stored in a dictionary and so Umbraco Commerce tries to convert that dictionary to an strongly typed object. It does this through JSON serialization and deserialization. It looks like having something that resembles JSON in a property value is causing confusion.
I'll have to dig into this, but just wondering if a coma separated string might do the trick? and if you then split it in your handler?
Hi @mattbrailsford Thanks for coming back so quickly. I can get it working if I escape the JSON string which seems to get automatically unescaped in the shipping provider! I guessed it was something to do with the JSON serialization and deserialization but I was finding it hard to track down exactly. Thanks!
Describe the bug
I am creating a custom shipping provider and I need to store a JSON value which is an array of objects in the shipping provider setting. I can get this working from the front-end, but when calculating the shipping rates it throws and JSON error. The same error happens when just adding square brackets into a normal text field setting and not even using any JSON:
If you inherit from ShippingProviderBase without using a settings class it works but if you try and use a settings class you get the error. Obviously without inheriting from the settings class you won't get the settings in the UI.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
Shipping provider settings should be able to store and retrieve strings with square brackets (including JSON strings) without throwing an error.
Umbraco Commerce version:
13.1.6
The text was updated successfully, but these errors were encountered: