- This topic has 10 replies, 3 voices, and was last updated 5 years, 11 months ago by
digger149.
-
AuthorPosts
-
-
March 10, 2016 at 6:25 am #6043
digger149MemberHello,
I am trying to build a simple ticketing system in Piklist. In simple terms, I have:
price per ticket – currently set to a default value, will be sent to the form
Select Quantity – 1,2 or 3
Update Total Cost based on price * quantity
I have been trying dozens of different methods, but I cannot figure out how to set $price in the code below:piklist('field', array( 'type' => 'text' ,'field' => 'price' , 'value' => '20' ,'label' =>'price' )) ; piklist('field', array( 'type' => 'select' ,'field' => 'master_field' ,'label' => 'Master field' ,'choices' => array( '1' => '1' ,'2' => '2' ,'3' => '3' ) ,'conditions' => array( array( 'type' => 'update' ,'value' => '1' ,'field' => 'my_field' ,'update' => 1*$price ) ,array( 'type' => 'update' ,'value' => '2' ,'field' => 'my_field' ,'update' => 2*$price ) ,array( 'type' => 'update' ,'value' => '3' ,'field' => 'my_field' ,'update' => 3*$price ) ) )); piklist('field', array( 'type' => 'text' ,'field' => 'my_field' ,'label' => 'Show/Hide Field' ,'value' => 1 * $price ,'description' => 'This field is updated by the Select field above' )); -
March 10, 2016 at 11:23 am #6053
SteveKeymaster -
March 10, 2016 at 7:46 pm #6060
jrcreativeMemberThat works globally, but it doesn’t allow you to change the price per post.
It seems like you’d want to do something like:
$price = get_post_meta(get_the_ID(), 'price', true) -
March 11, 2016 at 5:15 am #6062
digger149MemberThanks, but
It works if I say:
$price = '20';but it doesn’t (it returns zero) if I say:
$price = get_post_meta(get_the_ID(), 'price', true)The price of the ticket can vary, so it is a variable field in the form
-
March 11, 2016 at 5:36 am #6063
digger149MemberOn further investigation, I wanted to check out bits of the functionality
If I use
$price = get_the_ID();
It correctly finds the PostID and multiplies it, its is just not picking up the meta value for ‘price’ -
March 11, 2016 at 3:20 pm #6065
SteveKeymaster@digger149–
get_post_meta()works once the post is saved and the page refreshes.You may want to divide this up into Workflow tabs. The first tab can be your
pricefield, and the second tab can be the calculation. -
March 14, 2016 at 10:49 am #6071
digger149MemberYep, that was it – you need to save (update) the form before you can use the variables.
Can anyone think of a way round this?
-
March 15, 2016 at 1:33 am #6081
jrcreativeMemberIt’ll be a javascript or AJAX solution if you want real time data-binding.
-
March 16, 2016 at 6:45 am #6090
digger149MemberHi Steve
I’m struggling with how to get workflows on front end forms – is it possible?
Cheers
Ian -
March 16, 2016 at 11:29 am #6096
SteveKeymaster@digger149– Sorry, Workflows are an admin only feature right now.
-
March 16, 2016 at 11:48 am #6097
digger149MemberWould be great on the front-end as well.
Oh well, I will have to get my Jquery toolbox out
Many thanks for your help
-
-
AuthorPosts
- You must be logged in to reply to this topic.