Banner Logo

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

Required fields for Add Product

MultivendorX Pro

Resolved
Viewing 10 reply threads
  • Author
    Posts
    • #221853
      Picflick
      Participant

      Hi,
      You previously provided the following piece of code to assist with validating Required fields when a Vendor Adds a New Product:

      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_feature_image = isset( $_POST['featured_img'] ) ? $_POST['featured_img'] : '';
          $required_post_title = isset( $_POST['post_title'] ) ? $_POST['post_title'] : '';
      	$required_product_excerpt = isset($_POST['product_excerpt']) ? trim($_POST['product_excerpt']) : '';
          
          if (!$required_regular_price || !$required_feature_image || !$required_post_title || !$required_product_excerpt) {
              wc_add_notice( __('Please ensure you have added a Product Title, Image, Short Description, and Price', 'dc-woocommerce-multi-vendor'), 'error' );
              //redirect to main page
      		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

      But now suddenly, the wp_redirect is not working and it redirects the user to https://picflick.co.za/dashboard/. I need them to be redirected to the post that they were editing (either a new or existing one) – e.g. https://picflick.co.za/dashboard/edit-product/18218/.
      Please assist with editing the wp_redirect().
      Thanks, PicFlick

    • #221858

      Hello there, Please update your previously shared code snippet by replacing “wcmp” with “mvx” in the code and check if it works as needed to fulfill your requirement.

      Let us know if you need any further assistance.

    • #221890
      Picflick
      Participant

      Thanks. This did not work.
      It redirected the user to https://picflick.co.za/dashboard/general/18218

    • #221923

      Hello @Picflick, kindly add the below code in the functions.php file of your current active theme and check on your end –

      
      add_action( 'mvx_before_post_update', 'required_mvx_product_field' );
      function required_mvx_product_field() {
          $required_regular_price = isset( $_POST['_regular_price'] ) ? $_POST['_regular_price'] : '';
          $required_feature_image = isset( $_POST['featured_img'] ) ? $_POST['featured_img'] : '';
          $required_post_title = isset( $_POST['post_title'] ) ? $_POST['post_title'] : '';
          $required_product_excerpt = isset($_POST['product_excerpt']) ? trim($_POST['product_excerpt']) : '';
          
          if ( !$required_regular_price || !$required_feature_image || !$required_post_title || !$required_product_excerpt ) {
              wc_add_notice( __('Please ensure you have added a Product Title, Image, Short Description, and Price', 'dc-woocommerce-multi-vendor'), 'error' );
              // Redirect to main page
              wp_redirect( apply_filters( 'mvx_vendor_save_product_redirect_url', mvx_get_vendor_dashboard_endpoint_url(get_mvx_vendor_settings('mvx_edit_product_endpoint', 'seller_dashbaord', 'edit-product'), $_POST['post_ID'] ) ) );
              exit;
          }
      }
      
      
      Copy

      Let us know if you need any further assistance from our end.

    • #221997
      Picflick
      Participant

      Thanks Sangita – I used your code and the same thing happened (see: https://ibb.co/61KG3dg).

    • #221998

      Sorry to hear that the earlier shared code did not work for you. However, let me share this with the dev team and once I hear back from them I will keep you posted regarding the same.
      Thanks for your understanding.

    • #222075
      Picflick
      Participant

      Hi. Following up on this request please

    • #222078

      Apologies for the delay. Our development team has been occupied with their preassigned tasks and hasn’t had the chance to address your issue with the custom code yet. However, rest assured that as soon as they are available, they will look into your issue with the code and we will update you promptly. Thank you for your patience.

    • #222157

      Hello @Picflick, We have checked the code shared in the reply #221923 and it is working absolutely fine on our end. You can check the same here https://www.awesomescreenshot.com/video/30276325?key=0729150c5cc59846cea86b21ab2d1369.

      Now can you please share how the flow is working on your end with the updated code. So that we can look into it and understand it better.

    • #222174
      Picflick
      Participant

      Thank you very much. This code was key:
      wp_redirect( apply_filters( ‘mvx_vendor_save_product_redirect_url’, mvx_get_vendor_dashboard_endpoint_url(get_mvx_vendor_settings(‘mvx_edit_product_endpoint’, ‘seller_dashbaord’, ‘edit-product’), $_POST[‘post_ID’] ) ) );
      All working now! – appreciate it 🙂
      Post closed

    • #222175

      @Picflick, Thanks for the update.

      We are closing this thread. If you need help or face issues in future please do create a new support ticket.

Viewing 10 reply threads

The topic ‘Required fields for Add Product’ is closed to new replies.