Home Forums WoodMart support forum Add to cart slow on Android phones

Add to cart slow on Android phones

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #315905

    ajay_odedara
    Participant

    Hi There,

    I appreciate your help and support during the development of our site.

    Our site is Live now, but based on some user’s feedback Add to cart takes 5-6 seconds on Android devices. However, Windows and Mac work fine.

    Can you please help?

    #315995

    Artem Temos
    Keymaster

    Hi,

    Try to add the following PHP code snippet to the child theme functions.php file to fix this

    add_filter( 'woocommerce_add_to_cart_fragments', 'woodmart_cart_data', 30 );
    function woodmart_cart_data( $array ) {
    	ob_start();
    	woodmart_cart_count();
    	$count = ob_get_clean();
    
    	ob_start();
    	woodmart_cart_subtotal();
    	$subtotal = ob_get_clean();
    
    	$array['span.wd-cart-number_wd']   = $count;
    	$array['span.wd-cart-subtotal_wd'] = $subtotal;
    
    	return $array;
    }

    and put the following code to the Custom JS in Theme Settings

    jQuery( document.body ).on( 'added_to_cart removed_from_cart', function( e, fragments ){
    	if ( fragments ) {
    			jQuery.each( fragments, function( key, value ) {
    				jQuery( key.replace('_wd','') ).replaceWith( value );
    			});
    
    			jQuery( document.body ).trigger( 'wc_fragments_loaded' );
    		}
    });

    Then clear your browser cache and check the add to cart speed.

    Kind Regards

    #316117

    ajay_odedara
    Participant

    Legend, THANK YOU.

    I will try this code and test.

    #316198

    Artem Temos
    Keymaster

    You are welcome. Let me know if this solution works for you. It will be included in our next theme update.

Viewing 4 posts - 1 through 4 (of 4 total)