

We develop a eshop for a client that sells online courses. There are 3 packages in every course and the third one has to do with live instructor dates.
So , we thought that we want to show a modal button with text inside when the product has an option for a live instructor package.
We installed the anything popup plugin ( we had to hack the code to make it responsive! )
and we add a modal button right below the main image…
But the client told as that not every product has a live instructor package , so this button has to be shown only to the products they want…
What we did .
1. installed the WooCommerce Custom Product Data Fields
2. add this to functions.php . This creates a custom tab to the product
add_action('wc_cpdf_init', 'prefix_custom_product_data_tab_init', 10, 0);
if(!function_exists('prefix_custom_product_data_tab_init')) :
function prefix_custom_product_data_tab_init(){
$custom_product_data_fields = array();
/** First product data tab starts **/
/** ===================================== */
$custom_product_data_fields['custom_data_1'] = array(
array(
'tab_name' => __('Show dates', 'wc_cpdf'),
),
array(
'id' => '_mycheckbox',
'type' => 'checkbox',
'label' => __('Checkbox', 'wc_cpdf'),
'description' => __('Field description.', 'wc_cpdf'),
'desc_tip' => true,
)
);
return $custom_product_data_fields;
}
endif;
3. Add this code to the product-image.php
<?php
global $wc_cpdf; if ($wc_cpdf->get_value(get_the_ID(), '_mycheckbox'))
{
AnythingPopup( $pop_id = "1" ); }
else{
?>
<style type="text/css">.dates{
display:none;
}</style>
<?php
}
?> </div>
What this code does:
If the checkbox is checked shows the AnythingPopup( $pop_id = “1” );
else display nothing
That’s it!