Making fields in Add New Product required

WCMp Advanced Frontend Manager

Making fields in Add New Product required Resolved

Viewing 2 reply threads
  • Author
    Posts
    • #64987
      Dimitris Kuklis
      Participant

      Hey,

      I want to make the description, Image, regular price and shipping weight fields required in the dashboard.

    • #65018

      Hi @Dimitris Kuklis,
      thanks for your query.Please insert this below code in your current themes functions.php

      /**
      **required some wcmp product field 
      **/
      add_action( 'wcmp_before_post_update', 'required_wcmp_product_field' );
      function required_wcmp_product_field(){
          $required_regular_price = isset( $_POST['_regular_price'] ) ? $_POST['_regular_price'] : '';
          $required_product_description = isset( $_POST['product_description'] ) ? $_POST['product_description'] : '';
          $required_feature_image = isset( $_POST['featured_img'] ) ? $_POST['featured_img'] : '';
          $required_product_image = isset( $_POST['product_image_gallery'] ) ? $_POST['product_image_gallery'] : '';
          $required_shipping_weight_field = isset( $_POST['_weight'] ) ? $_POST['_weight'] : '';
          
          if(!$required_regular_price || !$required_product_description || !$required_feature_image || !$required_product_image || !$required_shipping_weight_field ){
              wc_add_notice( __('You have to add description,images,regualar price and shipping weight', '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;
          }
      }
    • #68681
      susmita
      Moderator

      Hi @dimitris Kuklis,
      I presume that your issue is resolved, since, we haven’t heard back from you.
      We are marking this thread as resolved.
      Kindly open a new thread if you face any further query.

Viewing 2 reply threads

The topic ‘Making fields in Add New Product required’ is closed to new replies.