WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Add to cart button with animation. (6 posts)

  1. wingye
    Member
    Posted 7 months ago #

    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 http://sushilab.nl/product-categorie/maki/ 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
    greetings,
    Wing

    http://wordpress.org/plugins/woocommerce/

  2. Roy
    Member
    Posted 7 months ago #

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

  3. wingye
    Member
    Posted 7 months ago #

    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.

    <?php
    /**
     * 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 : ?>
    
    	<?php 
    
    		switch ( $product->product_type ) {
    			case "variable" :
    				$link 	= get_permalink($product->id);
    				$label 	= apply_filters('variable_add_to_cart_text', __('Select options', 'woocommerce'));
    			break;
    			case "grouped" :
    				$link 	= get_permalink($product->id);
    				$label 	= apply_filters('grouped_add_to_cart_text', __('View options', 'woocommerce'));
    			break;
    			case "external" :
    				$link 	= get_permalink($product->id);
    				$label 	= apply_filters('external_add_to_cart_text', __('Read More', 'woocommerce'));
    			break;
    			default :
    				$link 	= esc_url( $product->add_to_cart_url() );
    				$label 	= apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce'));
    			break;
    		}
    
    		//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>
    
    			</form>
    			<?php
    
    		} 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; ?>
  4. Roy
    Member
    Posted 7 months ago #

    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.

  5. wingye
    Member
    Posted 7 months ago #

    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:/.

  6. wingye
    Member
    Posted 6 months ago #

    i found something like this but i cant get it to work
    http://mark.bloomfield.co.za/coding/styling-sexy-woocommerce-shop-messages

Reply

You must log in to post.

About this Plugin

About this Topic