This code places "price hints" after the price. I managed to delete all price hints or delete all prices totally but what I want is the price hints shown ONLY on single product pages.
I tried a lot but nothing worked.
Can anyone help?
/**
* WPBakeryVisualComposer: Price Infos after Price
*
* @since v3.8.1
* @wp-hook woocommerce_get_price_html
* @param String $price
* @param WC_Product $product
* @return String
*/
function wp_bakery_woocommerce_get_price_html( $price, $product ) {
$debug_backtrace = debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, 10 );
$has_loop_action = false;
foreach ( $debug_backtrace as $elem ) {
if ( $elem[ 'function' ] == 'woocommerce_de_price_with_tax_hint_loop' || $elem[ 'function' ] == 'woocommerce_de_price_with_tax_hint_single' || $elem[ 'function' ] == 'get_available_variation' ) {
$has_loop_action = true;
break;
} else if ( apply_filters( 'german_market_wp_bakery_price_html_exception', false, $elem[ 'function' ], $debug_backtrace ) ) {
$has_loop_action = true;
break;
}
}
foreach ( $debug_backtrace as $elem ) {
if ( $elem[ 'function' ] == 'vc_do_shortcode' ) {
ob_start();
add_filter( 'wgm_product_summary_parts', array( $this, 'theme_support_hide_gm_price_in_loop' ), 10, 3 );
echo WGM_Template::get_wgm_product_summary( $product, 'vc_do_shortcode' );
remove_filter( 'wgm_product_summary_parts', array( $this, 'theme_support_hide_gm_price_in_loop' ), 10, 3 );
$price .= ob_get_clean();
break;
} else if ( $elem[ 'function' ] == 'wp_bakery_woocommerce_get_price_html' ) {
if ( $has_loop_action ) {
return $price;
}
ob_start();
remove_filter( 'wgm_product_summary_parts', array( 'WGM_Template', 'add_product_summary_price_part' ), 0 );
echo '<div class="gm-wp_bakery_woocommerce_get_price_html">';
echo WGM_Template::get_wgm_product_summary( $product, 'wp_bakery_woocommerce_get_price_html' );
echo '</div>';
add_filter( 'wgm_product_summary_parts', array( 'WGM_Template', 'add_product_summary_price_part' ), 0, 3 );
$price .= ob_get_clean();
break;
}
}
return $price;
}
I tried a lot but nothing worked.
Can anyone help?
/**
* WPBakeryVisualComposer: Price Infos after Price
*
* @since v3.8.1
* @wp-hook woocommerce_get_price_html
* @param String $price
* @param WC_Product $product
* @return String
*/
function wp_bakery_woocommerce_get_price_html( $price, $product ) {
$debug_backtrace = debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, 10 );
$has_loop_action = false;
foreach ( $debug_backtrace as $elem ) {
if ( $elem[ 'function' ] == 'woocommerce_de_price_with_tax_hint_loop' || $elem[ 'function' ] == 'woocommerce_de_price_with_tax_hint_single' || $elem[ 'function' ] == 'get_available_variation' ) {
$has_loop_action = true;
break;
} else if ( apply_filters( 'german_market_wp_bakery_price_html_exception', false, $elem[ 'function' ], $debug_backtrace ) ) {
$has_loop_action = true;
break;
}
}
foreach ( $debug_backtrace as $elem ) {
if ( $elem[ 'function' ] == 'vc_do_shortcode' ) {
ob_start();
add_filter( 'wgm_product_summary_parts', array( $this, 'theme_support_hide_gm_price_in_loop' ), 10, 3 );
echo WGM_Template::get_wgm_product_summary( $product, 'vc_do_shortcode' );
remove_filter( 'wgm_product_summary_parts', array( $this, 'theme_support_hide_gm_price_in_loop' ), 10, 3 );
$price .= ob_get_clean();
break;
} else if ( $elem[ 'function' ] == 'wp_bakery_woocommerce_get_price_html' ) {
if ( $has_loop_action ) {
return $price;
}
ob_start();
remove_filter( 'wgm_product_summary_parts', array( 'WGM_Template', 'add_product_summary_price_part' ), 0 );
echo '<div class="gm-wp_bakery_woocommerce_get_price_html">';
echo WGM_Template::get_wgm_product_summary( $product, 'wp_bakery_woocommerce_get_price_html' );
echo '</div>';
add_filter( 'wgm_product_summary_parts', array( 'WGM_Template', 'add_product_summary_price_part' ), 0, 3 );
$price .= ob_get_clean();
break;
}
}
return $price;
}