Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

Make product short description mandatory for vendors when adding new products

WCMp Advanced Frontend Manager

Resolved
Viewing 4 reply threads
  • Author
    Posts
    • #134100
      raoul
      Participant

      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!

    • #134108
      raoul
      Participant

      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.

    • #134131

      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
    • #134137
      raoul
      Participant

      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.

    • #134194

      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
Viewing 4 reply threads

The topic ‘Make product short description mandatory for vendors when adding new products’ is closed to new replies.