Add event or configuration to set defaults for new products #3165
Unanswered
MoritzLost
asked this question in
Ideas
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to be able to specify default values for many of the product properties (stock, free shipping, availability, etc) that are available on every product by default. The defaults don't always make sense, and it's currently impossible to change them.
There are already some discussions on being able to set default values for specific fields:
But I think this should be solved more generally, allowing me to change defaults for any field, depending on the product's type.
I tried to solve this with a
Product::EVENT_BEFORE_SAVE
hook, but that doesn't work well. The hook is only triggered when the user saves the product for the first time. This means that when first creating a product, the edit form will not display those defaults, and any manually entered values will be overwritten when the product is first saved. See the related discussion here: https://craftcms.stackexchange.com/questions/40733/set-default-values-for-new-commerce-products/40775I think this could be solved in two ways:
I think this would also be solved if products supported the same draft workflow that entries do. For entries, the hook mentioned above works as intended, because creating a new entry immediately creates an unpublished draft, so the hook is triggered before the editor sees the entry form for the first time.
Beta Was this translation helpful? Give feedback.
All reactions