Skip to content

Instantly share code, notes, and snippets.

@chellestein
Last active July 12, 2022 20:25
Show Gist options
  • Save chellestein/5707791008fdfee28259fe1449c86a0b to your computer and use it in GitHub Desktop.
Save chellestein/5707791008fdfee28259fe1449c86a0b to your computer and use it in GitHub Desktop.
Remove Woocommerce Price and Cart for Paid Membership Pro Member Levels
/**
* @snippet Hide Price & Add to Cart for Paid Membership Pro Members
* @how-to Add to code snippets or functions.php in theme
* @customize Change 1,2 to your membership level ID numbers
* @author Chelle Stein
* @testedwith WooCommerce 6.6.1 and PaidMembershipsPro 2.8.3
*/
add_filter( 'woocommerce_get_price_html', 'cs_hide_price_addcart_members', 9999, 2 );
function cs_hide_price_addcart_members( $price, $product ) {
if(pmpro_hasMembershipLevel(array('1','2')))
{
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
else {
return $price;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment