Details panel – remove the price and “Add to cart” button

To hide the Price and Add-to-cart line in the details panel, add the following snippet to the functions.php file in your Child Theme (add the code to the end of the file), or install the Code Snippets plugin and apply this code as a snippet:

// Remove price from products in a details panel
add_filter( 'dgwt/wcas/suggestion_details/product/html', function($html){

	// Remove price
	$html = preg_replace('#<div class="dgwt-wcas-pd-price">(.+?)</div>#s', '', $html);

	// Remove "Add to cart" button
	$html = preg_replace('#<div class="dgwt-wcas-pd-addtc js-dgwt-wcas-pd-addtc">(.+?)</form>#s', '<div>', $html);

	return $html;

}, 10);

// Remove price from terms in a details panel
add_filter( 'dgwt/wcas/suggestion_details/term/html', function($html){

	// Remove price
	$html = preg_replace('#<div class="dgwt-wcas-tpd-price">(.+?)</div>#s', '', $html);

	return $html;

}, 10);

Before:

After:

Alternative method with CSS

If the price or “Add to cart” button can remain in the HTML source, you can hide it using CSS.

Hide price:

.dgwt-wcas-pd-price,
.dgwt-wcas-tpd-price {
     display: none;
}

Hide “Add to cart” button:

.dgwt-wcas-pd-addtc {
     display: none;
}