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
When setting up a payment methods preferences, you can define a default value if those preferences aren't explicitly set by the user. However, if the user is using static model preferences, these default values are not used.
Solidus Version:
2.10 - though likely an issue with more versions.
To Reproduce
Add a preference with a default value to a payment method
Create a static model preference source for the payment method that does not include the preference created in step 1
Set the payment method to use the static model preference
Try to access the new preference, get nil instead of the default value.
Current behavior
Accessing preferences not explicitly set in static model preferences returns nil instead of the default value
Expected behavior
Accessing preferences not explicitly set in static model preferences should return the default value
Screenshots
(default value with default preference source)
(default value with static preference source)
The text was updated successfully, but these errors were encountered:
Do you think there's a case when the user wouldn't want the defaults to be returned in the options hash? If we always return the preference defaults there will be no way to remove them with the static model preferences.
Ultimately, as a developer, I would expect something set as a default to always be returned as the default option (if nothing else is set). I think someone could make the case that setting static_model_preferences should override that expectation, but I'm not so sure - IMO it's just another way to set values to the preferences, in the same way that you'd set them on the payment_method.
I'm not sure that there's a use case for removing items from preferences - I think it makes more sense just to statically set them to something different (or just nil) if you don't want to use the default - but if there was a use-case for it, my initial feeling would be that we'd need an alternate way to remove the preferences - maybe from an initializer - rather than just not set the defaults when using static_model_preferences.
I guess another way of thinking about would be this: Currently, when you don't set a preference in static_model_preferences, it's true that it's not included in the preferences hash - but calling something that doesn't exist on a hash just returns nil - which is a value that can just be set in static_model_preferences if you don't want to use the preference for whatever reason. In short, you'd be able to achieve the same effect even if static_model_preferences did return the default value.
When setting up a payment methods preferences, you can define a default value if those preferences aren't explicitly set by the user. However, if the user is using static model preferences, these default values are not used.
Solidus Version:
2.10 - though likely an issue with more versions.
To Reproduce
nil
instead of the default value.Current behavior
Accessing preferences not explicitly set in static model preferences returns nil instead of the default value
Expected behavior
Accessing preferences not explicitly set in static model preferences should return the default value
Screenshots


(default value with default preference source)
(default value with static preference source)
The text was updated successfully, but these errors were encountered: