Hi, I have a question related to the Conditional Logic API.
I added a textarea field using the form customizer, and would like to have it hidden by default, but would only appear (and be required to fill in) when the number of tickets selected is geater than 1.
I tried to hook into the ‘ticketpicker’ field value for condition, and show the textarea field based on but could not make it work.
Something like this?
$textarea = $form->get_element( '8' );
$conditional_logic = array(
'action' => 'show',
'gate' => 'all',
'conditions' => array(
array(
'target' => 'ticketpicker',
'value' => 1,
'operator' => 'greaterthan',
)
),
);
$textarea->set( 'conditional', $conditional_logic );
Mikko Siikaniemi
Hi Mikko,
Unfortunately that won’t work with the ticketpicker, since the ‘value’ is not just the total number of tickets. For this, you’re going to need to implement itself. Something like:
jQuery(document).ready( function($) {
wp.hooks.addFilter( 'eventorganiser.checkout_cart', function( cart ){
if(cart.quantity > 1) {
$('#id_of_textarea').show();
} else {
$('#id_of_textarea').hide();
}
return cart;
}, 5 );
} );
You’ll need to ensure the textarea is not required has otherwise customers who purchase only one ticket will not be able to place the booking.
Stephen Harris