Support » Plugins » Hacks » Hide buy button on products with specific tags WP E-commerce

  • Hi.
    Using WP E-commerce and Storefront Elegance theme for an online store. Trying to use a product tag as a condition to hide the buy-button and quantity update (on the single product page) for some products that only can be bought in the physical store (can’t be shipped).

    I’ve tried with css and it works fine but only on one specific product (post-1928) and not on a whole product tag.

    Here’s the css:
    .post-1928.wpsc-product.type-wpsc-product .wpsc_quantity_update {
    display: none;
    .post-1928.wpsc-product.type-wpsc-product .productcol fieldset legend {
    display: none;
    .post-1928.wpsc-product.type-wpsc-product input.wpsc_buy_button {
    display: none;

    Here’s the test-product:
    Here’s the product tag:

    I’ve also tried a php code in the wpsc-single_product.php that hides the buy button if you’re not logged in.

    <?php if((get_option(‘hide_addtocart_button’) == 0) && (is_user_logged_in()) && (get_option(‘addtocart_or_buynow’) !=’1′)) : ?>

    That example works good but I don’t know what to put in instead to use the function for products with a specific tag. The tag is “demoex” (term-134).

    Would really appreciate some help here. I’ve been searching for days.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    I’ve ran into similar problem and managed to solve it, is your case still to be worked out? I see that your post is 5 months old 😉 please reply and i’ll try to help you

    Hi there,
    I still haven’t fixed this so I would really be glad for some assistans.

    What I like to do is to hide the buy button with css on a specific product category or on a product with a specific product tag.

    Here’s a test product I’m working with:

    Hi Gonerator.
    I’m still interested in your solution so if you have the time I’d be greatful.

    Moderator bcworkz


    Hi almerika,

    I’m sorry I’m not able to help with your actual problem. I just wanted to mention that people replying to posts such as Gonerator has done will often neglect to subscribe to the topic. Thus they are not notified when there is a new reply. The forum software will still notify members even if not subscribed when your place an ‘@’ in front of the username. It’s a useful way to maybe get someones attention. I’ll do it for you this time, as an example 🙂

    @gonerator – almerika would like to take you up on your kind offer of assistance.

    (let’s see if that helps any, good luck)

    @bcworkz here, take this karma. i missed mail after almerika’s post 🙂


    actually it’s fairly simple although it took me some time to figure it out 😛 code must be placed inside product_view div.

    if you need assistance in exactly hiding button bit, message me

    <?php $wpsc_product_tags = get_the_product_tags( wpsc_the_product_id() );
    if ($wpsc_product_tags) {
          foreach ($wpsc_product_tags as $wpsc_product_tag) {
           $tagslug = $wpsc_product_tag->slug;
    	if ($tagslug == 'someslug')
    	echo 'some_html_or_javascript';
    	}  ?>

    @bcworkz – thanks for your help

    Which file is the “product_view div” in?
    I’ve been looking in wpsc-single_product.php since that’s the only view showing the buy-button on this web, but I’m not sure where to put the code. There’s a place in that file looking like the code below. Should I paste it somewhere there?

    Another question. I’m not sure what parts I should change in the code you pasted. Could you make them bold?

    * Cart Options
    							<?php if((get_option('hide_addtocart_button') == 0) &&   (get_option('addtocart_or_buynow') !='1')) : ?>
    															<?php if(wpsc_product_has_stock()) : ?>
    									<div class="wpsc_buy_button_container">
    											<?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
    											<?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
    											<input class="wpsc_buy_button" type="submit" value="<?php echo wpsc_product_external_link_text( wpsc_the_product_id(), __( 'Buy Now', 'wpsc' ) ); ?>" onclick="return gotoexternallink('<?php echo esc_url( $action ); ?>', '<?php echo wpsc_product_external_link_target( wpsc_the_product_id() ); ?>')">
    											<?php else: ?>
    										<input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
    											<?php endif; ?>
    										<div class="wpsc_loading_animation">
    											<img title="Loading" alt="Loading" src="<?php echo wpsc_loading_animation_url(); ?>" />
    											<?php _e('Updating cart...', 'wpsc'); ?>
    										</div><!--close wpsc_loading_animation-->
    									</div><!--close wpsc_buy_button_container-->

    A big thank you in advance!

    I’m getting closer.

    Took your code and changed ‘someslug‘ to ‘testprodukt‘ which is the tag I’m testing with. After that I changed ‘some_html_or_javascript‘; to ‘<p>Testprodukt. Går ej att beställa.</p>‘ (in english that means you can’t order this test product). Works fine. The text is only displayed on the products with that tag. Here’s the test product:

    So now theres only one thing left. I need an action code that triggers to hide the addtocart-button on these products. Any clues?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Hide buy button on products with specific tags WP E-commerce’ is closed to new replies.