WordPress.org

Ready to get started?Download WordPress

Forums

Hide buy button on products with specific tags WP E-commerce (8 posts)

  1. almerika
    Member
    Posted 10 months ago #

    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: http://www.olsonsab.se/produkter/tillbehor/testprodukt-2/
    Here's the product tag: http://www.olsonsab.se/etikett/demoex/

    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.

  2. Gonerator
    Member
    Posted 5 months ago #

    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

  3. almerika
    Member
    Posted 5 months ago #

    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:
    http://www.olsonsab.se/produkter/tillbehor/testprodukt/

  4. almerika
    Member
    Posted 4 months ago #

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

  5. bcworkz
    Member
    Posted 4 months ago #

    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)

  6. Gonerator
    Member
    Posted 4 months ago #

    @bcworkz here, take this karma. i missed mail after almerika's post :)

    @almerika:

    actually it's fairly simple although it took me some time to figure it out :P 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';
          }
    	}  ?>
  7. almerika
    Member
    Posted 4 months ago #

    @bcworkz - thanks for your help

    @gonerator
    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!

  8. almerika
    Member
    Posted 4 months ago #

    @gonerator
    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: http://www.olsonsab.se/produkter/tillbehor/testprodukt/

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

Reply

You must log in to post.

About this Topic