Skip to content

Commit 24e0397

Browse files
authored
gspc-unlink-hidden-products-in-cart.php: Added snippet to remove links in the cart to products with a hidden visibility.
1 parent 52996d6 commit 24e0397

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Gravity Shop // Product Configurator // Unlink Hidden Products in Cart.
4+
* https://gravitywiz.com/documentation/gs-product-configurator/
5+
*/
6+
add_filter( 'woocommerce_cart_item_name', function ( $product_name, $cart_item, $cart_item_key ) {
7+
$product = $cart_item['data'];
8+
if ( ! ( $product instanceof WC_Product ) ) {
9+
return $product_name;
10+
}
11+
12+
// Remove the link for hidden products
13+
if ( $product->get_catalog_visibility() === 'hidden' ) {
14+
$product_name = strip_tags( $product_name );
15+
}
16+
17+
return $product_name;
18+
}, 10, 3 );

0 commit comments

Comments
 (0)