Unlink Hidden Products in Cart.

Code

Filename: gspc-unlink-hidden-products-in-cart.php

<?php
/**
 * Gravity Shop // Product Configurator // Unlink Hidden Products in Cart.
 * https://gravitywiz.com/documentation/gs-product-configurator/
 */
add_filter( 'woocommerce_cart_item_name', function ( $product_name, $cart_item, $cart_item_key ) {
	$product = $cart_item['data'];
	if ( ! ( $product instanceof WC_Product ) ) {
		return $product_name;
	}

	// Remove the link for hidden products
	if ( $product->get_catalog_visibility() === 'hidden' ) {
		$product_name = strip_tags( $product_name );
	}

	return $product_name;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.