Advertisement
palsushobhan

wcfm-custom_product_tab_edit_page

Aug 19th, 2024
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. add_action( 'after_wcfm_products_manage_grouped', function($product_id, $product_type) {
  2.     global $WCFM;
  3.     $cpt = wcfm_get_post_meta( $product_id, 'dummy_field', true);
  4. ?>
  5.     <!-- collapsible 2.x - Custom Product Tab -->
  6.     <div class="page_collapsible products_manage_cpt cpt simple variable grouped external" id="wcfm_products_manage_form_cpt_head"><label class="wcfmfa fa-object-group"></label><?php _e('Custom Product Tab', 'wc-frontend-manager'); ?><span></span></div>
  7.     <div class="wcfm-container cpt simple variable grouped external">
  8.         <div id="wcfm_products_manage_form_cpt_expander" class="wcfm-content">
  9.             <?php
  10.             $WCFM->wcfm_fields->wcfm_generate_form_field( apply_filters( 'product_manage_fields_grouped', array(      
  11.                 "dummy_field" => array('label' => __('Dummy Field', 'wc-frontend-manager') , 'type' => 'text', 'class' => 'wcfm-text wcfm_ele simple variable booking', 'label_class' => 'wcfm_title', 'value' => $cpt, 'placeholder' => __('Custom field value', 'wc-frontend-manager'), 'hints' => __( 'This is a custom hint.', 'wc-frontend-manager' ))
  12.             ), $product_id ) );
  13.             ?>
  14.         </div>
  15.     </div>
  16.     <!-- end collapsible -->
  17. <?php
  18. }, 10, 2 );
  19.  
  20. add_action( 'after_wcfm_products_manage_meta_save', function($product_id, $form_data) {
  21.     if( isset( $form_data['dummy_field'] ) ) {
  22.         wcfm_update_post_meta( $product_id, 'dummy_field', sanitize_text_field( $form_data['dummy_field'] ) );
  23.     }
  24. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement