Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter LolaEliz

    (@lolaeliz)

    Update: It’s a problem with my theme and the “variations” elements, and it’s a problem the theme creators are addressing. I did add some code that should have gotten rid of the cart button, and it did effect the cart on the shop page, same as the plug-in did. But that “add to cart” button already turns to “Select Variations” when there are variations, so It didn’t need to be deleted. It didn’t touch the home page. Thanks everyone for your help!!

    Thanks, everyone. I’m giving up on this fix. I don’t know enough about altering code to not break the site. (the plugin did not effect the home page, just the “shop” page, which didn’t have an add to cart button. I’m guessing the Organicstheme somehow overrides the woocommerce settings.

    Here is the woo commerce add-to-cart php. It’s probably not smart to mess with that, but it looks like this is where the loop is set up, and how it’s set up:

    <?php
    /**
     * Loop Add to Cart
     *
     * @author 		WooThemes
     * @package 	WooCommerce/Templates
     * @version     1.6.4
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    global $product;
    ?>
    
    <?php if ( ! $product->is_in_stock() ) : ?>
    
    	<a href="<?php echo apply_filters( 'out_of_stock_add_to_cart_url', get_permalink( $product->id ) ); ?>" class="button"><?php echo apply_filters( 'out_of_stock_add_to_cart_text', __( 'Read More', 'woocommerce' ) ); ?></a>
    
    <?php else : ?>
    
    	<?php
    		$link = array(
    			'url'   => '',
    			'label' => '',
    			'class' => ''
    		);
    
    		$handler = apply_filters( 'woocommerce_add_to_cart_handler', $product->product_type, $product );
    
    		switch ( $handler ) {
    			case "variable" :
    				$link['url'] 	= apply_filters( 'variable_add_to_cart_url', get_permalink( $product->id ) );
    				$link['label'] 	= apply_filters( 'variable_add_to_cart_text', __( 'Select options', 'woocommerce' ) );
    			break;
    			case "grouped" :
    				$link['url'] 	= apply_filters( 'grouped_add_to_cart_url', get_permalink( $product->id ) );
    				$link['label'] 	= apply_filters( 'grouped_add_to_cart_text', __( 'View options', 'woocommerce' ) );
    			break;
    			case "external" :
    				$link['url'] 	= apply_filters( 'external_add_to_cart_url', get_permalink( $product->id ) );
    				$link['label'] 	= apply_filters( 'external_add_to_cart_text', __( 'Read More', 'woocommerce' ) );
    			break;
    			default :
    				if ( $product->is_purchasable() ) {
    					$link['url'] 	= apply_filters( 'add_to_cart_url', esc_url( $product->add_to_cart_url() ) );
    					$link['label'] 	= apply_filters( 'add_to_cart_text', __( 'Add to cart', 'woocommerce' ) );
    					$link['class']  = apply_filters( 'add_to_cart_class', 'add_to_cart_button' );
    				} else {
    					$link['url'] 	= apply_filters( 'not_purchasable_url', get_permalink( $product->id ) );
    					$link['label'] 	= apply_filters( 'not_purchasable_text', __( 'Read More', 'woocommerce' ) );
    				}
    			break;
    		}
    
    		echo apply_filters( 'woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="%s button product_type_%s">%s</a>', esc_url( $link['url'] ), esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( $link['class'] ), esc_attr( $product->product_type ), esc_html( $link['label'] ) ), $product, $link );
    
    	?>
    
    <?php endif; ?>

    (I tried that piece of code someone above mentioned and it crashed things so I took it out.)

    If you choose your variations, you get an add to cart button on the products page.

    The ADD TO CART on the homepage is completely functionless. That’s why I want to remove it.

    This is the only ADD TO CART code I found in the home file:

    <a class="add_btn" href="<?php echo $_product->add_to_cart_url(); ?>"><?php _e("Add To Cart", 'organicthemes'); ?></a>
    		                	<?php } else { ?>
    		                		<a class="add_btn" href="<?php echo $product->add_to_cart_url(); ?>"><?php _e("Add To Cart", 'organicthemes'); ?></a>

    THANK YOU!!!!
    Lola

    Hi Michael,

    Here is the link http://LOLAcaninecouture.com

    click “add to cart” — you will see it returns to the homepage. I want no “add to cart” here, but yes on the individual product page. I want to sell, but I don’t want “add to cart” to work from the homepage. Because it can’t work there — every item has variations. You need to go to the product page to order.

    Someone above said to put this code in the functions file. It looks logical, like it will do what I want. I don’t know if it needs to be in a special place in that file. Can I just put it as the last item in that file?

    thank you so much!
    Lola

    function remove_loop_button(){
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    }
    add_action('init','remove_loop_button');

    How about a way to add nofollow to the add to cart function? That sounds like an easier fix. Anyone know how to do that? Thank you!!

    Thanks Guys!

    I don’t think If Menu works with my theme. I went to the menu section after installing and activating it and there was no indication that the plugin was there. Plus, I don’t think it will solve the issue.

    I think maybe I wasn’t clear. It’s not the cart in the navigation menu that I want to remove — unless removing it from the navigation bar removes it from each item on the home page.

    On my homepage, each product is displayed, I guess on a loop because I didn’t put them there. Each as an “add to cart” button and a “View Products” button. The “add to cart” returns to the homepage — not to the product page and it adds nothing to the cart — so I end up with 30-some duplicate pages of the home page and google doesn’t like that.

    Michael —

    I’m a novice. Where do I put this code? (sorry to seem dumb about it.) Also, just to be clear, this will only remove the “add to cart” function from the homepage loop? It will still stay on the individual product page?

    <?php (is_page('home'));
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
     ?>

    Michael,

    Will one of those codes hide just the add to cart button on the homepage? I don’t want to hide the price, I just want to disable the add to cart button. Having it there it reroutes every product on the page to the homepage which is creating an SEO issue of duplicate content. I’d be happy with just making it nofollow. I don’t mind it being there, I just don’t want the duplicate content issue. Thanks!
    I made the site and know a little about code, but I’m no pro, FYI)

    http://lolacaninecouture.com

    Thread Starter LolaEliz

    (@lolaeliz)

    http://LOLAcaninecouture.com

    It’s a bug with woocommerce. I googled it and a lot of people have this issue. I couldn’t find an solution for it though. No one seemed to care with the SEO issue it creates. Thanks for your help! LOLA

Viewing 10 replies - 1 through 10 (of 10 total)