Home Forums WoodMart support forum Page loading speed is very slow – Example Add to cart function

Page loading speed is very slow – Example Add to cart function

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #315640

    BP1989
    Participant

    i am in development stage and when i add my product to cart – there is a long delay in response – around 6 seconds

    what might be the issue – internet speed?

    i have my woodmart theme hosted on fast comet ultra fast plan

    #315665

    Hello,

    Thank you very much for choosing our theme and for contacting us.

    Please, provide your site admin access (insert the site credentials into the Private content block under the message area) and confirm the permission for plugins deactivation, switching to the parent or default theme. This testing may take up to 15 minutes. You would better make the full backup of your site.

    Best Regards

    #315671

    BP1989
    Participant

    Hello please find the credentials

    #315723

    BP1989
    Participant

    hello,

    kindly solve the above issue asap.

    i have chosen the child theme for development based on the recommendation – is it the problem for slow loading of the pages

    #315746

    Artem Temos
    Keymaster

    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.

    #315749

    BP1989
    Participant

    hi thank u for quick response

    #315825

    Artem Temos
    Keymaster

    You are welcome! Let me know if you have any further questions.

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

The topic ‘Page loading speed is very slow – Example Add to cart function’ is closed to new replies.