shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Show Instruction bar before boxes

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?

  1. Install and activate the ACF plugin on your site.
  2. 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

  1. Install and activate the ACF plugin on your site.
  2. Visit the Custom Field page > add new
    • Add a new field group.
  3. On the product page add Instruction text to the field created.
  4. 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 );

Updated on February 4, 2021
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Was this article helpful?

shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Related Articles