WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
'woocommerce_ajax_add_to_cart' button not visible (1 post)

  1. nicolas-t
    Member
    Posted 1 year ago #

    Hi,

    -When I call the function do_action( 'woocommerce_simple_add_to_cart' ); my button "add to cart" is visible

    -When I replace it with this function do_action( 'woocommerce_ajax_add_to_cart' );
    no button are created. (no errors are returned)

    -var_dump(do_action( 'woocommerce_ajax_add_to_cart' ));
    returns NULL

    -I'm working on templates/content-product.php (i've enabled AJAX from the admin panel)

    By the way, when I use this bbcode [add_to_cart id="" sku=""] to create an "add to cart" button in the description of the product it works perfectly (ajax).

    Here is my code :

    <?php
    /*
    	template/content-product.php page
    */
    
    global $product, $woocommerce_loop;
    
    if ( empty( $woocommerce_loop['loop'] ) )
    	$woocommerce_loop['loop'] = 0;
    
    if ( empty( $woocommerce_loop['columns'] ) )
    	$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
    
    if ( ! $product->is_visible() )
    	return;
    
    $woocommerce_loop['loop']++;
    ?>
    <?php do_action( 'woocommerce_before_shop_loop_item' ); ?>
    
    <div class="column-right-product">
    
    	<?php $product = new WC_Product( get_the_ID() ); ?>
        	blah blah blah
            <?php 
    
    	/* here is the problem */
    
    	//do_action( 'woocommerce_simple_add_to_cart' );
    	do_action( 'woocommerce_ajax_add_to_cart' );
    	?>
    </div>

    thank you very much for your help,

    Nicolas

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic