I’ve a customized subject created for WooCommerce merchandise.
I’m utilizing the under code to create
// ADD CUSTOM WOO DATA
add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields');
// Save Fields
add_action('woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save');
operate woocommerce_product_custom_fields()
{
international $woocommerce, $submit;
echo '<div class="product_custom_field">';
// Customized Product Textual content Subject
woocommerce_wp_text_input(array(
'id' => '_sales_email',
'placeholder' => '',
'label' => __('Gross sales E mail Hyperlink', 'woocommerce'),
'desc_tip' => 'true'
));
echo '</div>';
}
operate woocommerce_product_custom_fields_save($post_id)
{
// Customized Product Textual content Subject
$woocommerce_custom_product_text_field = $_POST['_sales_email'];
if (!empty($woocommerce_custom_product_text_field))
update_post_meta($post_id, '_sales_email', esc_attr($woocommerce_custom_product_text_field));
}
The Code works nicely, and shows the info on the product web page.
I’m displaying the info through a shortcode.
<div class="dbtn_sales"><a href="mailto:[foobar name=_sales_email]">E mail Gross sales</a></div>
The issue I’m having is hiding the info if the sphere is empty..
I’ve tried
if( get_field('_sales_email') )
{
//echo the_field('_sales_email');
}
else
{
echo "<type>.dbtn_sales{show:none !vital;}</type>";
}
however I am getting nowhere… Can anybody level me in the suitable course right here?