I am unable to create custom fields through WooCommerce Hooks as shown
function woocommerce_product_custom_fields()
{
global $woocommerce, $post;
echo '<div class="product_custom_field">';
woocommerce_wp_text_input(
array(
'id' => '_custom_product_title',
'placeholder' => 'Arabic Product Title',
'label' => __('Arabic Product Title', 'woocommerce'),
'desc_tip' => 'true'
)
);
woocommerce_wp_textarea_input(
array(
'id' => '_arabic_desc',
'placeholder' => 'Arabic Description',
'label' => __('Arabic Description', 'woocommerce')
)
);
echo '</div>';
}
// Display Fields
add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields');
function woocommerce_product_custom_fields_save($post_id)
{
// Custom Product Text Field
$woocommerce_custom_product_text_field = $_POST['_custom_product_title'];
if (!empty($woocommerce_custom_product_text_field))
update_post_meta($post_id, '_custom_product_title', esc_attr($woocommerce_custom_product_text_field));
/*$woocommerce_custom_product_textarea = $_POST['_arabic_desc'];
if (!empty($woocommerce_custom_product_textarea))
update_post_meta($post_id, '_arabic_desc', esc_html($woocommerce_custom_product_textarea));*/
}
// Save Fields
//add_action('woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save');
But the Fields do not appear in Admin panel > New Products or in the Vendor > Add product pages.
I found two mentions in the WP.org from the WooCommerce authority here also this thread
So, did they just remove the functionality of these hooks in free method? Why wont that be documented then?
**
Update: I was looking at the wrong place to see the code running. And as the asnwerer reported it worked for him. I checked more to find out any output this could have generated, and found that, I had a tab collapsed which was recently updated due to WooCommerce plugin update at the previous day. Of course was some frustrating moments for a couple of days. Partly was for the typos I had at the 2nd TextArea name initially, but later it was due to collapsed tab and expecting result at another dashboard run by WCMarketPlace (another addon for vendors from WooCommerce).
**