• Resolved seb7100

    (@seb7100)


    Hi,

    I have found some code, that hides all product prices if users are not logged in. However, I would like it to only hide prices on a category-slug with ‘carel’. Is this possible to add in this code below:

    // Hide prices
    add_action(‘after_setup_theme’,’magik_activate_filter’) ;

    function magik_activate_filter()
    {
    add_filter(‘woocommerce_get_price_html’, ‘magik_show_price_logged’);
    }

    function magik_show_price_logged($price)
    {
    if(is_user_logged_in() )
    {
    return $price;
    }
    else
    {
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
    remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );
    return ‘Log ind for at se priser‘;
    }
    }`

    • This topic was modified 3 years, 2 months ago by seb7100.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @seb7100,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thanks.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide price of products in category if not logged in’ is closed to new replies.