mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-28 11:22:21 +08:00
11 lines
649 B
Text
11 lines
649 B
Text
add_filter( 'woocommerce_get_price_html', 'astra_hide_price_addcart_not_logged_in', 9999, 2 );
|
|
|
|
function astra_hide_price_addcart_not_logged_in( $price, $product ) {
|
|
if ( ! is_user_logged_in() ) {
|
|
$price = '<div><a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">' . __( 'Login to see prices', 'astra' ) . '</a></div>';
|
|
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 );
|
|
add_filter( 'woocommerce_is_purchasable', '__return_false' );
|
|
}
|
|
return $price;
|
|
}
|