Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Change checkbox display on single product page
- This topic has 9 replies, 2 voices, and was last updated 5 years ago by WCFM Forum.
- AuthorPosts
- October 2, 2019 at 2:24 pm #84764cartaclaudioParticipant
Hi,
I have 2 custom check boxes, one called pre-order and the other explicit. I would like to modify their display so that it does not show when left empty. I would also like to display it in a different way which will show the universal explicit image instead of just a checkbox.
I am trying to figure out a way of doing this through functions.php, yet I have encountered a brick wall.
How can this be achieved please?
Attachments:
You must be logged in to view attached files. - October 11, 2019 at 9:42 am #86170WCFM ForumMember
HI,
Please use this line to your site –
add_filter( 'wcfm_is_allow_custom_field_display_by_icon', '__return_false' );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/Thank You
- October 14, 2019 at 12:29 pm #86793cartaclaudioParticipant
Thank you so much. with this code it displays the word no instead of an icon. is it possible to not display the field at all if left unchecked?
Regards,
Claudio - October 16, 2019 at 12:06 pm #87077WCFM ForumMember
Hi,
Please add this code to your site –
add_filter( 'wcfm_custom_field_value', function( $field_value, $field_name, $product_id, $field_type ) { if( $field_type == 'checkbox' ) { if( $field_value == 'no' ) { $field_value = ''; } else { $field_value = get_post_meta( $product_id, $field_name.'_checkbox', true ); } } return $field_value; }, 50, 4 );
Thank You
- October 25, 2019 at 1:33 pm #89011cartaclaudioParticipant
Hi,
I have added this code to functions.php, the function is getting in but when the field_values are no(tested by var_dump) they are still producing the checkbox post meta.
- November 5, 2019 at 7:54 pm #90868WCFM ForumMember
HI,
This code will hide label if checkbox is not checked!
Thank You
- November 21, 2019 at 6:20 pm #93283cartaclaudioParticipant
Hi,
I have been testing a playing around with this one, however it does not work. When the field_value is ” its returning everything as checked instead of hiding the value.
- November 23, 2019 at 11:57 am #93583WCFM ForumMember
Well, this code only works for checkbox type fields.
- December 15, 2019 at 4:12 pm #97545cartaclaudioParticipant
Thanks this works great like this
add_filter( 'wcfm_custom_field_value', function( $field_value, $field_name, $product_id, $field_type ) { if( $field_type == 'checkbox' ) { if( $field_value == 'no' ) { add_filter( 'wcfm_is_allow_custom_field_display_by_icon', '__return_false' ); $field_value = ''; } else { if( $field_name == 'explicit' ) { add_filter( 'wcfm_is_allow_custom_field_display_by_icon', '__return_false' ); $field_value = '<img src="http://XXXXXXX/wp-content/themes/themify-music-child/images/explicit.png" width="64px" />'; }else { $field_value = get_post_meta( $product_id, $field_name.'_checkbox', true ); } } } return $field_value; }, 50, 4 );
is there a filter I can use to hide the checkboxes name from appearing in a label?
- December 24, 2019 at 10:22 am #98875WCFM ForumMember
HI,
is there a filter I can use to hide the checkboxes name from appearing in a label?
– Sorry, don’t get this. Please show me scree shot for this.
Thank You
- AuthorPosts
- The topic ‘Change checkbox display on single product page’ is closed to new replies.