WCMp Advanced Frontend Manager
-
AuthorPosts
-
-
February 6, 2022 at 12:02 AM #134100raoulParticipant
Hi,
Is there a way to ensure that vendors can only submit new products if they have added a short description? This would be great as I always have to reject products because there is no short description.
It would also be cool to show an error message if they vendor does not add a short description. Something like ‘you must add a short description before submitting a product’.
Is this possible to do with a code snippet?
Thanks a lot!
-
February 6, 2022 at 1:59 PM #134108raoulParticipant
Just to clarify, I’m referring to when vendors add new products through the vendor dashboard. It would be cool to show an error message on the vendor dashboard when a vendor tries to add a product without a short description.
-
February 7, 2022 at 2:40 PM #134131NerdySupportExpert MoumitaKeymaster
In order to make the short description mandatory, please add this code in the function.php of the plugin :
/** **required some wcmp product field **/ add_action( 'wcmp_before_post_update', 'required_wcmp_product_field' ); function required_wcmp_product_field(){ $required_product_short_description = isset( $_POST['product_short_description'] ) ? $_POST['product_short_description'] : ''; if(!required_product_short_description){ wc_add_notice( __('You have to add short description', 'dc-woocommerce-multi-vendor'), 'error' ); wp_redirect( apply_filters( 'wcmp_vendor_save_product_redirect_url', wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_edit_product_endpoint', 'vendor', 'general', 'edit-product' ), $_POST['post_ID'] ) ) ); exit; } }
Copy -
February 7, 2022 at 2:47 PM #134137raoulParticipant
Thanks for the code. I just adding this but when testing it, it didn’t work. I’ve added a screenshot showing that I managed to submit a product through the dashboard with no short description or price.
-
February 8, 2022 at 6:17 PM #134194NerdySupportExpert MoumitaKeymaster
Sorry, please use this updated code :
add_action( 'wcmp_before_post_update', 'required_wcmp_product_field' ); function required_wcmp_product_field(){ $required_shipping_weight_field = isset( $_POST['product_short_description'] ) ? $_POST['product_short_description'] : ''; if( !$required_shipping_weight_field ){ wc_add_notice( __('You have to add description', 'dc-woocommerce-multi-vendor'), 'error' ); wp_redirect( apply_filters( 'wcmp_vendor_save_product_redirect_url', wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_edit_product_endpoint', 'vendor', 'general', 'edit-product' ), $_POST['post_ID'] ) ) ); exit; } }
Copy
-
-
AuthorPosts
The topic ‘Make product short description mandatory for vendors when adding new products’ is closed to new replies.