Please help: Replace order or delete content of Woocommerce archive or single product pages

e195

Member
Aug 24, 2019
53
13
8
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;
}
 

SharkTanker

Tech Guru
Trusted Uploader
Oct 30, 2018
388
648
93
corporatehitech.com.au
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;
}
Hello,

Every person that known me very well know that I hate WooCommerce. So, couldn't you simply hide which ever part of the product price you want gone? just hide the class for it.
 
  • Like
Reactions: theglassguy

e195

Member
Aug 24, 2019
53
13
8
I can put css : none but then it does also not show on single product page.

It seems this code and also the CSS do not distinguish between archive pages and single product page.
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu