Support » Plugin: WooCommerce » Add to cart button with animation.

  • Hi Woocommerce,

    I am struggling with a problem for quite some time now. I handcraft this theme and implemented woocommerce to sell stuff on the site. Everything is working out well except 1 lil thing i cant find the answer for.

    On my page There is a list of products all i want is when i press toevoegen it would just stay there and show an icon for successfully added to my cart instead of jump to top ( refresh ) the page.

    This may sounds very simple for you guys but i have been spending loads of time trying to figure it out, but without any luck i am seeking for your help.

    I hope you guys can help me out with this Tiny problem..

    Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Roy Ho


    WC has ajax add to cart. Did you turn that on?

    Sorry for my late reply did you mean in the settings? Ye its checked.
    And below is the coe for my Add to cart loop.

     * Loop Add to Cart
    global $product; 
    if( $product->get_price() === '' && $product->product_type != 'external' ) return;
    <?php if ( ! $product->is_in_stock() ) : ?>
    	<a href="<?php echo get_permalink($product->id); ?>" class="button"><?php echo apply_filters('out_of_stock_add_to_cart_text', __('Read More', 'woocommerce')); ?></a>
    <?php else : ?>
    		switch ( $product->product_type ) {
    			case "variable" :
    				$link 	= get_permalink($product->id);
    				$label 	= apply_filters('variable_add_to_cart_text', __('Select options', 'woocommerce'));
    			case "grouped" :
    				$link 	= get_permalink($product->id);
    				$label 	= apply_filters('grouped_add_to_cart_text', __('View options', 'woocommerce'));
    			case "external" :
    				$link 	= get_permalink($product->id);
    				$label 	= apply_filters('external_add_to_cart_text', __('Read More', 'woocommerce'));
    			default :
    				$link 	= esc_url( $product->add_to_cart_url() );
    				$label 	= apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce'));
    		//printf('<a href="%s" rel="nofollow" data-product_id="%s" class="button add_to_cart_button product_type_%s">%s</a>', $link, $product->id, $product->product_type, $label);
    		if ( $product->product_type == 'simple' ) {
    			<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'>
    			 	<?php woocommerce_quantity_input(); ?>
    			 	<button type="submit" class="button alt" ><?php echo $label; ?></button>
    		} else {
    			printf('<a href="%s" rel="nofollow" data-product_id="%s" class="add_to_cart_button button product_type_simple product_type_%s">%s</a>', $link, $product->id, $product->product_type, $label);
    <?php endif; ?>
    Roy Ho


    If you turned it on and it still doesn’t work in your product category pages, then I have to suggest you try 2012 theme. You will see it works there.

    This is a theme thats been craft by me its not a standart theme. I tried to look at the other theme but without luck:/.

    i found something like this but i cant get it to work

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add to cart button with animation.’ is closed to new replies.