duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
143 stars 36 forks source link

[5.x] Add "Save Zero Value?" option to Money fieldtype #918

Closed duncanmcclean closed 11 months ago

duncanmcclean commented 11 months ago

This pull request adds a new "Saves Zero Value?" option to the Money fieldtype, ensuring that a Price/Total field is always saved as £0.

Fixes #916.

Use Case

I have a case where I have an order blueprint where all the total fields are set as required (as per the default Simple Commerce blueprint).

However, commonly, not all the fields (like the Coupon Total) will actually be set due to the Money field being null/empty. This meant that when I go to save an entry in the orders collection, I can't because it requires the total fields to be some value.

History

From history, I've gone back on forward as to what the default should be here - whether it should always save £0 (which it should IMO) or whether it should save empty, like it does now.

There was an issue a while ago which prompted the change to the way it is now: #459

For now, the behaviour is opt-in (it'll continue to save empty but you can choose to let it save as £0). However, this will likely turn into being opt-out when v6 is released.

github-actions[bot] commented 11 months ago

Released as part of v5.4.0.