Last active
October 17, 2020 19:22
-
-
Save zenideas/11866a7fc17518e0df7bf9a3a48871af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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_short_desc', | |
'placeholder' => __('Arabic Short Description'), | |
'label' => __('Arabic Short Description', 'woocommerce') | |
) | |
); | |
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 | |
$wccp_title = $_POST['_custom_product_title']; | |
if (!empty($wccp_title)) | |
update_post_meta($post_id, '_custom_product_title', esc_attr($wccp_title)); | |
$wccp_short_desc = $_POST['_arabic_short_desc']; | |
if (!empty($wccp_short_desc)) | |
update_post_meta($post_id, '_arabic_short_desc', esc_html($wccp_short_desc)); | |
$wccp_desc = $_POST['_arabic_desc']; | |
if (!empty($wccp_desc)) | |
update_post_meta($post_id, '_arabic_desc', esc_html($wccp_desc)); | |
} | |
add_action('woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check reply from WooCommerce support here
And also at this page