Banner Logo

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

Add Field at ‘General Tab’ (vendor dashboard)

WCMp Advanced Frontend Manager

Resolved
Viewing 9 reply threads
  • Author
    Posts
    • #135346
      Klaus Thomas Russ
      Participant

      Dear all,

      I would like to add a custom field named ‘Einheitspreis’ at the General tab. I have attached an image showing you where the text field should appear. Is it also possible to show the filled text field on each product preview (product listing) and also on each single product page (both underneath the regular price)? Which snippet can I add to the functions.php to meet that target?

      Best regards and thanks in advance!

    • #135370

      @Klaus Thomas Russ, thanks for getting in touch with us.

      In order to add an extra field, you need to do custom code. Do you have any developers so we can assist you accordingly?

    • #135399
      Klaus Thomas Russ
      Participant

      Dear Nerdy,

      yes, we have a developer that can add/change some custom code. So how should we proceed?

      Best regards!

    • #135430

      Klaus, please use this action

      do_action( 'wcmp_afm_before_general_product_data', $post->ID, $product_object, $post );
      Copy

      For further help, please check this : https://github.com/wcmarketplace/dc-woocommerce-multi-vendor/blob/master/templates/vendor-dashboard/product-manager/views/html-product-data-general.php

    • #135515
      Klaus Thomas Russ
      Participant

      Dear Nerdy,

      the following code was added to html-product-data-general.php to create a custom field named ‘Einheitspreis’ (please see the attached image):

      line 50 – 58:
      <div class=”form-group-row”>
      <div class=”form-group”>
      <label class=”control-label col-sm-3 col-md-3″ for=”einheitspreis”><?php echo __( ‘Einheitspreis’, ‘dc-woocommerce-multi-vendor’ ); ?></label>
      <div class=”col-md-6 col-sm-9″>
      <input type=”text” id=”einheitspreis” name=”einheitspreis” class=”form-control”>
      </div>
      </div>
      </div>

      Well, the custom field appears under the General Tab, but the data won’t be saved. Which code or snippet do we have to add too, so that the data will be saved and appears on the product page and also on the product overview in the listings?

      Best regards,
      Klaus

    • #135546

      Hi,
      kindly use below code to save the data

      /*
       Save Custom Tab content data.
      */
       
      function save_custom_general_data( $product, $post_data ) {
      if( isset($post_data['post_ID']) && isset($post_data['einheitspreis'])) {
      	update_post_meta( absint( $post_data['post_ID'] ), 'einheitspreis', $post_data['einheitspreis']);
      	}
      }
      add_action( 'wcmp_process_product_object', 'save_custom_general_data', 100, 2 );
      Copy

      regards

    • #135624
      Klaus Thomas Russ
      Participant

      Hi,

      I added this code to the functions.php, but unfortunately the data still won’t be saved. The problem still exists…

    • #135639
      This reply has been marked as private.
    • #135702
      Klaus Thomas Russ
      Participant

      Hi, you can close the ticket. I found an other solution… But thanks for your support.

    • #135721

      Thanks for the update.

Viewing 9 reply threads

The topic ‘Add Field at ‘General Tab’ (vendor dashboard)’ is closed to new replies.