Thursday, May 10, 2012

WP-E-commerce - How to hide 'Add to Cart' button if your user is not logged in

I have been searching and searching for WEEKS on how to do this, and now that I figured it out, it seems so obvious! I thought I would post the answer here for all of you that are as stubborn as me and are still trying:

In both wp-content>plugins>wp-e-commerce>wpsc-theme>wpsc-products_page.php and wp-content>plugins>wp-e-commerce>wpsc-theme>wpsc-single_product.php, change this line:
<?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
to this:
<?php if((get_option('hide_addtocart_button') == 0) && (is_user_logged_in()) && (get_option('addtocart_or_buynow') !='1')) : ?>
Basically, saying if the user is logged in, show the 'add to cart' button, otherwise, don't.

Ah! Now don't we all feel better?

No comments:

Post a Comment