Custom fields cookie/user meta
-
Hello,
I have added my custom “checkbox” fields to “mt-fields-api.php” and left everything else default. My custom fields display below the tickets on event page and the form seems to send the correct JSON data (i.e. tickets and custom fields that are selected).
The issue is that when the “Add to cart” button is pressed and I “Go to cart”, then go back to the event page and update my selection, the data gets added together when I press “Add to cart” again and “Go to cart” again. It seems that the cookie/user meta is not clearing and just gets accumulated.
I tried clicking “Empty cart” link but it only removes tickets but not custom field meta and hidden input fields on cart/purchase page.
How can I force all cookie/user meta to firstly be removed and only then send JSON data when “Add to cart” pressed?
Thank you in advance.
This is my custom fields code just in case (Not sure if all is correctly setup):
add_filter( 'mt_custom_fields', 'create_custom_fields', 10, 2 ); function create_custom_fields( $array ) { $array['test_event_data1'] = array( 'title'=>"Extra Option 1", 'sanitize_callback'=>'sanitize_callback', 'display_callback'=>'display_callback', 'input_type'=>'checkbox', 'input_values'=>'Extra Option 1', 'context'=>'global' ); $array['test_event_data2'] = array( 'title'=>"Extra Option 2", 'sanitize_callback'=>'sanitize_callback', 'display_callback'=>'display_callback', 'input_type'=>'checkbox', 'input_values'=>'Extra Option 2', 'context'=>'global' ); return $array; } function display_callback( $data, $context ) { return urldecode( $data ); } function sanitize_callback( $data ) { return esc_sql( $data ); }
- The topic ‘Custom fields cookie/user meta’ is closed to new replies.