Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Vendors › Required
Tagged: required
- This topic has 8 replies, 2 voices, and was last updated 6 years, 9 months ago by WCFM Forum.
- AuthorPosts
- February 5, 2018 at 11:10 am #18679hakanbasaran1978Participant
I want to change some sections as required on the add product page. I show the sections on the attached photos. How i can change them as required?
Attachments:
You must be logged in to view attached files. - February 5, 2018 at 11:33 am #18682WCFM ForumMember
Hi,
Thanks for get in touch with us.
Yeah, it’s possible but have to add some custom code for these.
Let me send that in few hours.
Thank You
- February 6, 2018 at 6:56 am #18710hakanbasaran1978Participant
Ok Thank You Im Waiting..
Best Regards,
Hakan - February 6, 2018 at 10:17 am #18721WCFM ForumMember
Hi,
Kindly add this code to your child theme’s functions.php it will make price and stock fields required –
function wcfm_required_product_fields_pricing( $price_fields, $product_id, $product_type ) { if( isset( $price_fields['regular_price'] ) ) { $price_fields['regular_price']['custom_attributes'] = array( 'required' => 1 ); } return $price_fields; } add_filter( 'wcfm_product_manage_fields_pricing', 'wcfm_required_product_fields_pricing', 50, 3 );
function wcfm_required_product_fields_stock( $stock_fields, $product_id, $product_type ) { if( isset( $stock_fields['manage_stock'] ) ) { $stock_fields['manage_stock']['dfvalue'] = 'enable'; $stock_fields['manage_stock']['custom_attributes'] = array( 'required' => 1 ); } if( isset( $stock_fields['stock_qty'] ) ) { $stock_fields['stock_qty']['custom_attributes'] = array( 'required' => 1 ); } return $stock_fields; } add_filter( 'wcfm_product_fields_stock', 'wcfm_required_product_fields_stock', 50, 3 );
For rests some JavaScript required, I will send those to you soon as well.
Please know me is this works for you or not!
Thank You
- February 6, 2018 at 10:30 am #18722WCFM ForumMember
Hi,
Here is another PHP code snippet to mark “Tags” input required –
function wcfm_required_product_fields_tags( $tag_fields ) { if( isset( $tag_fields['product_tags'] ) ) { $tag_fields['product_tags']['custom_attributes'] = array( 'required' => 1 ); } return $tag_fields; } add_filter( 'product_simple_fields_tag', 'wcfm_required_product_fields_tags', 50 );
Thank You
- February 6, 2018 at 4:36 pm #18727hakanbasaran1978Participant
Yess All is Working Thank You ..
Featured Image
Description
CategoriesI am waiting for the codes for 3 sections above. Thank you very much for your help.
Kings Regards
Hakan - February 7, 2018 at 2:47 pm #18753WCFM ForumMember
Hi,
Here is the code for those three fields –
function wcfm_product_manage_custom_validation( $general_fields, $product_id, $product_type ) { ?> <script> // WCFM Form Custom Validation jQuery(document).ready(function($) { $( document.body ).on( 'wcfm_form_validate', function() { // Featured Image $featured_img = $('#featured_img').val(); if( !$featured_img ) { if( $wcfm_is_valid_form ) $('#wcfm-main-contentainer .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Featured Image: This field is required.' ).addClass('wcfm-error').slideDown(); else $('#wcfm-main-contentainer .wcfm-message').append( '<br /><span class="wcicon-status-cancelled"></span>Featured Image: This field is required.' ); $wcfm_is_valid_form = false; } // Product category $product_cats = $('#product_cats').val(); if( !$product_cats ) { if( $wcfm_is_valid_form ) $('#wcfm-main-contentainer .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Categories: This field is required.' ).addClass('wcfm-error').slideDown(); else $('#wcfm-main-contentainer .wcfm-message').append( '<br /><span class="wcicon-status-cancelled"></span>Categories: This field is required.' ); $wcfm_is_valid_form = false; } // Description $description = ''; if( $('#description').hasClass('rich_editor') ) { if( tinymce.get('description') != null ) { $description = tinymce.get('description').getContent({format: 'raw'}); $description = $($description).text(); } } else { $description = $.trim($('#description').val()); } if( !$description ) { if( $wcfm_is_valid_form ) $('#wcfm-main-contentainer .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Description: This field is required.' ).addClass('wcfm-error').slideDown(); else $('#wcfm-main-contentainer .wcfm-message').append( '<br /><span class="wcicon-status-cancelled"></span>Description: This field is required.' ); $wcfm_is_valid_form = false; } }); }); </script> <?php return $general_fields; } add_filter( 'wcfm_product_manage_fields_general', 'wcfm_product_manage_custom_validation', 50, 3 );
Please know me is this works for or not!
Thank You
- February 9, 2018 at 7:36 am #18793hakanbasaran1978Participant
Thank You ,
All is Working
Best Rgrsds,
Hakan - February 9, 2018 at 11:47 am #18816WCFM ForumMember
Hi,
Thanks for confirming me this.
If you ever get a chance then please give me a review – https://wordpress.org/support/plugin/wc-frontend-manager/reviews/
Thank You
- AuthorPosts
- The topic ‘Required’ is closed to new replies.