blog

Showing products price if logged in or for a specific product

I have some code that is blocking the price from appearing on all products if the user is not logged in.

My problem is that I have 1 product free of charge and if the user is not logged in I need to show the price. Showing products price

Can someone help me target that single product by its ID and display this special value even if the user is not logged in?

Here is my original PHP code in funcions.php which prevents the user from showing the price when the user is not logged in.

 function codemanHouse_woocommerce_template_loop_price() {
    if ( is_user_logged_in() )
        woocommerce_get_template( 'loop/price.php' );
}
function woocommerce_template_single_price() {
    if ( is_user_logged_in() )
        woocommerce_get_template( 'single-product/price.php' );
}
function woocommerce_template_loop_add_to_cart() {
    if ( is_user_logged_in() )
        woocommerce_get_template( 'loop/add-to-cart.php' );
}
add_filter('inti','codemanHouse_woocommerce_template_loop_price');


Show product price when not using code any user can see product price

when code using on the functions.php file just show the image

Woocommerce – hide top right cart icon unless logged in user

Hide menu cart for logged out users completely

 

if your needed cart icon hide Website Show cart icon After Login Please read the code and insert the functions.php file or child theme

function Codeman_house_woocommerce_template_single_add_to_cart() {
    global $product;
    if ( is_user_logged_in() )
        do_action( 'woocommerce_' . $product->product_type . '_add_to_cart'  ); 
}
add_filter('init','Codeman_house_woocommerce_template_single_add_to_cart');


Woocommerce – hide top right cart icon unless logged in user

Remove login and shopping cart icons from home page

To hide the login & cart from the homepage only, copy this into Customize > Additional CSS:

.home .top-login,
.home .top-cart {
    display: none;
}

If you want to hide login & cart on any other page, you would use the page ID like so:

.page-id-23 .top-login,
.page-id-23 .top-cart {
    display: none;
}

 

if your need only plugin using if can using for this plugin is good understanding working I’m more then implement another website

Plugin Name is

Hide Price Until Login

Description

Hide products on the product and product details page until the user is logged in or entering the password. it is a very helpful plugin

1.Hides the price of the product until the correct password is entered
2.Hides the price of the product for a specific user
3.Hides the price of the product until the user is logged in
4.Hides prices from the shop page and product details page as well
5.No one hides the price of the product
6.Only one product description is displayed on the store page, or it is a 7.general product.
8.Fully customizable, most things are dynamic and can be 9.customized by admin.
10.Enable / Disable all features of the plugin
11.Skilled only for legitimate users.
12.Easy to use and must be installed
13.Easy to configure
14.Show / hide password fields.
15.Great language support