This can be achieved using the Advanced custom fields (ACF) plugin.
You have to add a custom field to the product you want the instruction bar to be displayed on.
How to add a field?
- Install and activate the ACF plugin on your site.
- Install and activate the cpb-instruction-bar plugin.
- Visit the product edit page and add the Instruction text in the cpb_instruction_text field.
- View the product in the frontend.
OR
- Install and activate the ACF plugin on your site.
- Visit the Custom Field page > add new
- Add a new field group.
- On the product page add Instruction text to the field created.
- Copy the below code to your child themes functions.php file. In the below code replace the meta key ‘cpb_instruction_text’ with your created meta key.
/**
* Filters the text to show before instruction before box.
*
* @since 4.1.0
* @param string $text Default Instruction text.
* @return string $text
*/
function cpb_addon_selection_instruction_text_function( $text ) {
global $product;
return ! $product->is_type( 'wdm_bundle_product' ) ? $text : get_post_meta( $product->get_id(), 'cpb_instruction_text', true );
}
add_filter( 'cpb_addon_selection_instruction_text', 'cpb_addon_selection_instruction_text_function' );
/**
* Get HTML to show instruction before box.
*
* @since 4.1.0
* @param object $cpb_product Box product object.
* @param array $addon_list List of addons.
* @return void
*/
function cpb_before_box_instruction_function( $cpb_product, $addon_list ) {
if ( ! $cpb_product->is_type( 'wdm_bundle_product' ) ) {
return;
}
wc_get_template(
'/single-product/cpb-before-box-instruction.php',
array(),
'custom-product-boxes/',
CPB()->plugin_path() . '/templates/' . CPB()->cpb_template_folder(),
);
}
add_action( 'cpb_before_box_wrap', 'cpb_before_box_instruction_function', 10, 2 );