I have a Product Type where every product has the same price. What are some good ways to avoid having to enter this same price for every product?

1 Answer 1


I don't think there is a way to do this from the back end data entry point of view currently - that is, right now, the price field is required, and indeed is required to be a number. You can't use e.g. the value of another field in there (in which case you could have used e.g. a global or something to store a single record of the price elsewhere).

The other solution would be to deal with it via a plugin - you could listen to https://craftcommerce.com/docs/events-reference#commerce_lineitems.onpopulatelineitem and intercept this product, setting the price for the lineItem in there. You could make a setting field in your plugin to store the actual price so there was a UI based way of changing it globally easily. However, you'd still have to enter some price in the product when entering the product, something token like 0.01 perhaps. Not perfect from a UI point of view and easily misunderstood by anyone coming new to the back end.

Ideally, and it might we worth making a feature request to P & T for this - a price field that can parse twig and pulls values from elsewhere - this could certainly be very handy.

Another option would be to write a product importer and deal with the data entry that way - so that the price is set at the time of import of the data. There's a gist that would get you started with here - https://gist.github.com/lukeholder/bbff8caef82078fc76e4

All said and done, though, this might be just one of those instances where you have to just deal with the data entry (at the moment) - it all depends of course whether the extra work/maintenance of an importer or plugin is worth doing (which all depends on how many products you're talking about and perhaps how often the price would change).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.