• Hi there, i have two cpts “room” and “booking”. Room does have some generic fields eg. name, size. Booking does have some generic fields eg. firstname, lastname, time and rooms. The frontend does have a form where you can book the rooms (mulitple choices possible). On submit i use the wp_insert_post function to insert the data to the booking cpt. Here i store the firstname, lastname and the choosen rooms (ids if rooms). I can view all bookings in wordpress backend. This is easy and works fine.

    Now my question: At the booking-process, i will integrate a field like “quantity” but i dont know how store this and how i get it to the wordpress backend.

    Thanks for help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter danielwerner23

    (@danielwerner23)

    I’ve stored in a meta field as json string. It works. Maybe later i create a custom input where i can edit these json string.

    Moderator bcworkz

    (@bcworkz)

    Keeping data in JSON format is OK as long as you don’t need to query for posts using an element of JSON as selection criteria. It can be done, but the query is very inefficient. If you need to select posts based on a meta value, it’s best if the value was in its own field.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get relationship between CPT and quantity’ is closed to new replies.