acf form on product frontend

WCMp Advanced Frontend Manager

acf form on product frontend Open

Tagged: 

Viewing 4 reply threads
  • Author
    Posts
    • #105509
      mrharmonies
      Participant

      hello good people of wcmp-land,
      ive added a few ACF fields in product custom post type and would like to make the field editable in frontend, say in General Tab (add/edit product). ive seen a few post about adding forms to frontend but mostly its based on toolkit type (https://wc-marketplace.com/support-forum/topic/custom-product-data-general-tab/). is there any guide to add acf form field to wcmp frontend?

    • #105552
      mrharmonies
      Participant

      basically im stuck here. im able to get the form appear in general tab. is this even a correct way to add acf form into frontend? how do i get the current product or post_id? how do i make my acf form follow wcmp beautiful styling? can i hide the update button and did the wcmp main Update button update the acf form?

      Attachments:
    • #105574
      abhirup
      Moderator

      Hi,

      please add this code in the function.php of the current active theme :

      modify below code as you want.

      add_action( 'wcmp_afm_after_general_product_data','wcmp_general_tab_field',1,3);
      function wcmp_general_tab_field($post_ID, $product_object, $post){?>
         <div class="form-group">
         <?php $custom_field = get_post_meta($product_object->get_id(),'custom_field',true); ?>
             <label class="control-label col-sm-3 col-md-3" for="custom_field"><?php echo __( 'Label Name', 'dc-woocommerce-multi-vendor' ) ; ?></label>
             <div class="col-md-6 col-sm-9">
                 <input type="text" id="custom_field" name="custom_field" value="<?php echo(!empty($custom_field))?$custom_field:'';  ?>" class="form-control">
             </div>
         </div>
      <?php
      }
      
      add_action( 'wcmp_process_product_object','wcmp_save_extra_product_field',10,2);
      
      function wcmp_save_extra_product_field($product, $post_data ){
         if( isset($post_data['post_ID']) && isset($post_data['custom_field'])) {
             update_post_meta( absint( $post_data['post_ID'] ), 'custom_field', $post_data['custom_field']);
         }
      }
      Copy

      Thank You.

    • #105658
      mrharmonies
      Participant

      thanks for the reply. your code works. however, do you have acf specific solution? i heard wcmp have good integration with acf and i thought the process will be easier with less code, maybe using acf_form() where i dont have to pull acf value for line 7, the_field(‘field-name’,$post_ID) for every field i want to display in frontend?

    • #105675
      abhirup
      Moderator

      Hi,
      WCMP Advance Frontend Manager Plugin is compatible with ACF you can check it.
      If you want to create a custom form on edit product page(under general tab) then please use below hook

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

      using this hook you will get the product id.

      Thank You.

Viewing 4 reply threads

Please LOGIN to reply to this topic

Buy all Marketplace addons together, check out our Bundle

Buy at Slashed Price