1

I have a custom textarea filed for the product page.

woocommerce_wp_textarea_input(
    array(
        'id' => '_custom_product_calc',
        'label' => __('Test', 'woocommerce')
    )
);

$woocommerce_custom_product_calc = $_POST['_custom_product_calc'];
if (!empty($woocommerce_custom_product_calc))
    update_post_meta($post_id, '_custom_product_calc', esc_html($woocommerce_custom_product_calc));

I need to use this field for insert some HTML code with JS. But, as you can see, the result is not what I've expected.

enter image description here

How can I change this? Or, maybe you know a better way to add a tab with HTML and JS for a product page? Clone Short description, for example?

Thanks!

1
  • 2
    I don't use WooCommerce so I have a bad understanding of the whole context. With that said, if you change your esc_html to wp_kses and supply it with an array of legal tags and their allowed attributes, you might get what you need. Though this looks like it's escaping when saving instead of outputting, which seems like the wrong way to go about this. Commented Dec 4, 2019 at 16:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.