RensTillmann / super-forms

18 stars 14 forks source link

Use Custom Types Fields #29

Closed arantawi closed 4 years ago

arantawi commented 4 years ago

Hi,

Hope you are fine and happy.

I have a pre-sale question and didn't know where to post it, so please:

I have "Hotels_Offers" wordpress custom type with "offer_price" custom field.

(1) Can I populate a Dropdown element to have the records of this custom type (Hotels_Offers) in a Super Form?

(2) and when user selects an offer from that Dropdown element to use "offer_price" field in calculations?

To explain: if the user selects "Marriott Hotel" from the Dropdown element which contains all hotels offers, the price is $100 per night.. then he selects number of days (say 5).. the price will be $500.

RensTillmann commented 4 years ago

Hi, these are more questions, not bug reports or feature requests. But I will try to answer your questions.

The dropdown element has a setting called Retrieve method, which you can set to Specific posts (post_type). You can choose this method, and then define the Post type: offer_price.

Now the next thing is crucial, you must set Retrieve Slug, ID, Title or Meta Data as value to Custom post meta data

And then you will have to define the meta data which holds the price (which I obviously don't know). So as an example you could define the following:

ID
_price_metakey

where _price_metakey is of course the meta key that is used in your post.

Now that you have a dropdown with the offers, and with the values in the format of: 1234,100 (1234 being the post ID, and 100 the price retrieved via metadata). You can grab the {tag} of the dropdown field and retrieve either of the 2 values. In your case you'd want to use the price value in your calculator (I am guessing you are using calculator Add-on). Which you can do with {tag;2}.

Of course replace tag with the fieldname of the dropdown e.g: {hotel_offers;2}

More info in the documentation about tags system: https://renstillmann.github.io/super-forms/#/tags-system

arantawi commented 4 years ago

Thank you very much. I will do my best to try it hopefully very soon.