0

I really don't know if this is possible or not, but i can accept a alternative solution too. Here is what I gonna do:

I have a barbershop post type, this cpt has a taxonomy called service. Well, no problem so far. Every barbershop I register, has different services, but every service in every barbershop has a different price, right?

Is this something I can implement in wordpress? I want to do it with custom post type(barbershop), taxonomies(services) and taxonomy metadatas(price).

If this is possible with these wordpress concepts, I want to know how. But if you have another solution to implement this or you think it's not possible at all, I'm glad to hear it.

0

Yes and no. Ofcourse you can do it, but that doesn't mean it's a great way to do it, or the fastest or easiest way.

You could give every barber shop its own term that has a price, but then you gain a whole host of new problems.

Instead, lets retreat to the fundamentals and rethink things.

  • Post meta is for details about an individual post
  • Taxonomies are for grouping, filtering, searching, querying.

So first, are the prices of services individual to a barber shop? Yes! They should be post meta

But do we want to flag barber shops as offering a service? Yes! So use a taxonomy

So now we have:

  • A Barber CPT
  • A taxonomy that stores which services they provide
  • Each barber post has meta values that detail the price of said service at the barber shop ( also known sometimes as custom fields )

I would also recommend adding a taxonomy for how expensive the place is, e.g. when you see options such as $,$$,$$$,$$$$, or 1-10,11-20,etc in filters. Querying the price directly and letting the user type in an exact value is possible but very expensive and slow ( post meta is designed for fetching details about a post when you already know which post it is, taxonomies are for when you don't know the post ).

So for example, if you have a service named "Beard trim" and the terms slug is beard-trim, why not add a custom field named price-beard-trim and store a price in there?

2
  • I have to many services, is that a good idea to add a price custom field for everyone of them? Can it be dynamic to just add the price field for services I need, while writing the post?
    – Amirition
    Jun 8 '18 at 10:22
  • Unless you have tens of thousands of services I doubt it will be an issue, besides, you need to add a price for every single one anyway, barbers don't standardise prices and each Barber has unique prices
    – Tom J Nowell
    Jun 9 '18 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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