__('Custom Product Options', 'my_text_domain'), 'target' => 'wcpa_product-meta-tab', 'priority' => 90 ); return $product_data_tabs; } public function woocommerce_process_product_meta_fields_save($post_id) { // This is the case to save custom field data of checkbox. You have to do it as per your custom fields $meta_field = array(); $form_order= array(); if (isset($_POST[WCPA_PRODUCT_META_FIELD])) { foreach ($_POST[WCPA_PRODUCT_META_FIELD] as $v) { $form_id = (int) sanitize_text_field($v); $meta_field[] = $form_id; if(isset($_POST['wcpa_product_meta_order']) && isset($_POST['wcpa_product_meta_order'][$form_id]) && $_POST['wcpa_product_meta_order'][$form_id]!==''){ // null and 0 need to be treated as different, if value is null, it will order based on the form default order $form_order[$form_id] = (int) sanitize_text_field($_POST['wcpa_product_meta_order'][$form_id]); } } } // asort($form_order); update_post_meta($post_id, WCPA_PRODUCT_META_KEY, $meta_field); update_post_meta($post_id, wcpa_product_meta_order, $form_order); if (isset($_POST['wcpa_exclude_global_forms'])) { update_post_meta($post_id, 'wcpa_exclude_global_forms', true); } else { update_post_meta($post_id, 'wcpa_exclude_global_forms', false); } if (!wcpa_get_option('wcpa_cf_bind_external',false) && isset($_POST['wcpa_product_cf']) && is_array($_POST['wcpa_product_cf'])) { $wcpa_product_cf = $_POST['wcpa_product_cf']; $custom_fields = wcpa_get_option('product_custom_fields'); $cf_prefix = wcpa_get_option('wcpa_cf_prefix','wcpa_pcf_'); foreach($custom_fields as $k=>$field){ if(isset($wcpa_product_cf[$k]) && !empty($wcpa_product_cf[$k])){ update_post_meta($post_id, $cf_prefix.$field['name'], $wcpa_product_cf[$k]); }else{ delete_post_meta($post_id, $cf_prefix.$field['name']); } } } } public function add_my_custom_product_data_fields() { $cf_prefix = wcpa_get_option('wcpa_cf_prefix','wcpa_pcf_'); global $post; $ml = new WCPA_Ml(); $meta_class = ''; if ($ml->is_active() && $ml->current_language()!==false && !$ml->is_default_lan() ) { $meta_class = 'wcpa_wpml_pro_meta'; } ?>
is_active() && $ml->current_language()!==false && !$ml->is_default_lan()) { echo '

' . sprintf(__('You can manage form fields from base language only.')) . '

'; } ?>

ID, WCPA_PRODUCT_META_KEY, true); $form_order = get_post_meta($post->ID, 'wcpa_product_meta_order', true); $forms = get_posts(array('post_type' => WCPA_POST_TYPE, 'posts_per_page' => -1)); if ($ml->is_active()) { $forms = $ml->get_original_forms(); } $show_order_number = wcpa_get_option('wcpa_show_form_order',false); foreach ($forms as $v) { $checked = ''; if ($meta_field && is_array($meta_field) && in_array($v->ID, $meta_field)) { $checked = 'checked="checked"'; } if($form_order && isset($form_order[$v->ID])){ $form_order_val= $form_order[$v->ID]; }else{ $form_order_val= ''; } echo '

' . ''; if($show_order_number){ echo ''; } echo '

'; } ?>

ID, 'wcpa_exclude_global_forms', true), true, false) . ' name="wcpa_exclude_global_forms" id="wcpa_exclude_global_forms" value="1">' . '

'; ?>

$field) { ?>

value="ID, $cf_prefix . $field['name'], true) ?>" placeholder="Enter value">