Support » Plugin: Ajax Cart AutoUpdate for WooCommerce » Theme from scratch need help to instal

  • Resolved keusta

    (@keusta)


    Hello Taisho,

    i started to create a theme from scratch and i disabled all wp headers calls so there’s no ajax js files related and for sure nothing works when i update the cart.
    What do i need to able from woocommerce to let your plugin work properly ?

    Thanks
    config with the latest versions

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author taisho

    (@taisho)

    Hello,

    on the cart page no CSS and no inline JavaScript from Ajax Cart AutoUpdate is loaded. No CSS is the reason why Update Cart button is still visible. I don’t see any option to change the quantity of the product, so even if JavaScript was loaded, there is no use for my plugin if it’s impossible to change product quantity in your cart.

    This website looks like a very custom work. While there are .woocommerce class elements, I didn’t notice any styling coming directly from WooCommerce at all. It could be the reason why the style from my plugin and the script which uses WooCommerce function to show up inline is also missing.

    My plugin works only on the cart page, so you could use the following in your child theme’s functions.php file to check on cart page load if “true” appears:

    add_action ('init', 'acau_test' );
    function acau_test() {
        echo is_cart();
    }

    If “false” shows up on the top left corner, it would mean that your cart page is not properly detected as a cart page by WooCommerce.

    Best regards,

    Ryszard

    • This reply was modified 4 months, 2 weeks ago by taisho.
    • This reply was modified 4 months, 2 weeks ago by taisho.
    • This reply was modified 4 months, 2 weeks ago by taisho.

    Hello Ryszard, and thanks for the quick reply.

    There’s a product in the shop with name “quantité de 3 produits – test stock” wich have 3 in stock for the test. Maybe you dont see it. All others products are single – only 1 in stock.

    So i need your plugin just for this case.
    My cart page is the same as the last wc template. if is_cart is working well.
    maybe it will work if i hard code the link to your css and js file ?
    how does your files is loaded ? via wp-header ?

    I voluntarily deleted calls to woocommerce files (css and js) because i want to make my own template (html + css + js)

    do you think it’s better to integrate your plugin to my template as files or keep the plugin by adding hooks ?

    Plugin Author taisho

    (@taisho)

    After testing the cart page for the product with the changeable quantity, here are my findings:

    1. Plugin CSS and JS isn’t loaded.
    2. The default setting to change the minimum quantity in the cart from 0 to 1 may or may not work. You could test it by changing it in plugin settings. The minimum is 1, but it can be 1 either from Ajax Cart AutoUpdate or WooCommerce not applying this default minimum because of custom changes.
    3. The default WooCommerce Ajax event on pressing the “Update cart” button doesn’t work. The page is fully reloaded. My plugin is based on this event and won’t work without it.

    This is how the style to hide the button is added (cart page only):
    add_action( 'wp_head', 'acau_hide_update_cart_button', 20 );

    This is how the script is added, using a WooCommerce helper function wc_enqueue_js which is probably disabled on your website (cart page only):

    add_action( 'template_redirect', function() use ( $args ) { ajax_cart_autoupdate( $args ); });
    function acau_enqueue_script( $args ) {
    	
    	wc_enqueue_js( '
    	
    		var timeout;
    
    		jQuery("div.woocommerce").on("change keyup mouseup", "input.qty, select.qty", function(){ // keyup and mouseup for Firefox support
    			if (timeout != undefined) clearTimeout(timeout); //cancel previously scheduled event
    			if (jQuery(this).val() == "") return; //qty empty, instead of removing item from cart, do nothing
    			timeout = setTimeout(function() {
    				jQuery("[name=\"update_cart\"]").trigger("click");
    			}, ' . $args["update_delay"] . ' ); // schedule update cart event with delay in miliseconds specified in plugin settings
    		});
    		
    	' );
    	
    }

    $args["update_delay"] is the numeric value set in plugin settings.

    Due to how the plugin is connected to WooCommerce functionality, it will be extremely difficult to make it work without WooCommerce in its default state.

    • This reply was modified 4 months, 2 weeks ago by taisho.

    Thx for the reply.
    will try a lot and get back if im stuck 🙂

    Plugin Author taisho

    (@taisho)

    For now, I’ll mark it as resolved, if you need further assistance, you can set the status to “not resolved” and post in this thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.