Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Update Custom Cart Count (or any HTML) after AJAX Add to Cart in WooCommerce

//header or woocommerce.php
<div class="header-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div>
//function file
add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );

function iconic_cart_count_fragments( $fragments ) {
    
    $fragments['div.header-cart-count'] = '<div class="header-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>';
    
    return $fragments;
    
}
Comment

PREVIOUS NEXT
Code Example
Php :: php preplace 
Php :: php file upload code not working in ubuntu 
Php :: no sass folder in laravel 
Php :: php show hide td 
Php :: Laravel unique Validation with multiple input value 
Php :: laravel translation parameter send 
Php :: php insert in array 
Php :: financial year calculation in php 
Php :: php How to remove from a multidimensional array all duplicate elements including the original 
Php :: cant upload file to directory php 
Php :: table laravel 
Php :: jsondecode 
Php :: coinbase commerce laravel 
Php :: true not true acf 
Php :: php website templates free download with database 
Php :: set border phpoffice phpexcel 
Php :: remove null values from array php 
Php :: php find in array 
Php :: laravel delete method 
Php :: php 30days 
Php :: laravel get next and previous record 
Php :: php RFC3339 
Php :: php password_hash 
Php :: SIMPLE linked list in php 
Php :: laravel skip a loop if error 
Php :: cpanel composer update kill 
Php :: php constants 
Php :: laravel showing index of problem 
Php :: mailjet 
Php :: how to update dropdown value in laravel 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =