Save Custom Fields & Retrieve Data From DB

WCMp Vendor Staff

Save Custom Fields & Retrieve Data From DB Resolved

Viewing 2 reply threads
  • Author
    • #68783

      Hello There

      I am trying to add custom fields to submit product in vendor dashboard, i used snippet i found in this forum , written by your experts, and this is the snippet i used :

      * Add Custom Tab in add product page.
      * @author WC Marketplace
      * @Version 3.3.0
      function add_custom_product_data_tabs( $tabs ) {
      $tabs[‘advanced’] = array(
      ‘label’ => __( ‘Custom Tab’, ‘your-text-domain’ ),
      ‘target’ => ‘custom_tab_product_data’,
      ‘class’ => array(),
      ‘priority’ => 100,
      return $tabs;
      add_filter( ‘wcmp_product_data_tabs’, ‘add_custom_product_data_tabs’ );

      * Add Custom Tab content in add product page.
      * @author WC Marketplace
      * @Version 3.3.0
      function add_custom_product_data_content( $pro_class_obj, $product, $post ) {
      <div role=”tabpanel” class=”tab-pane fade” id=”custom_tab_product_data”> <!– just make sure tabpanel id should replace with your added tab target –>
      <div class=”row-padding”>
      <div class=”form-group”>
      <label class=”control-label col-sm-3 col-md-3″>Custom Text Field</label>
      <div class=”col-md-6 col-sm-9″>
      <input type=”text” name=”custom_text_field” class=”form-control” />
      add_action( ‘wcmp_product_tabs_content’, ‘add_custom_product_data_content’, 10, 3 );

      * Save Custom Tab content data.
      * @author WC Marketplace
      * @Version 3.3.0
      function save_custom_product_data( $product, $post_data ) {
      if( isset($post_data[‘post_ID’]) && isset($post_data[‘custom_text_field’])){
      update_post_meta( absint( $post_data[‘post_ID’] ), ‘_custom_text_field’, $post_data[‘custom_text_field’]);
      add_action( ‘wcmp_process_product_object’, ‘save_custom_product_data’, 10, 2 );

      my questions are
      1 – how can i test this snippet works fine and the data has been saved to DB?
      2 – how can i retrieve the data for this custom field from DB and display it in product view page. ? ( Kindly , can you provide another snippet to do this demand)

      Best Regards

    • #68825
      WCMp Support

      H @JackMoonLight3i, thanks for getting in touch with us.

      You can refer to this link, which is to add new fields and save the same in Database :

    • #75553

      Hi @JackMoonLight3i,

      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 ‘Save Custom Fields & Retrieve Data From DB’ is closed to new replies.

WCMp bundle is available at a slashed price

Grab It Now