Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Update WooCommerce Cart

add_action( 'wp_footer', 'bbloomer_cart_refresh_update_qty', 9999 );

function bbloomer_cart_refresh_update_qty() {
     if ( is_cart() || ( is_cart() && is_checkout() ) ) {
          ?>
          <style type="text/css">
            input[name='update_cart'] {
                display: none !important;
            }
             /* OR TRY THIS */
 
	     button[name='update_cart']
            {display: none !important;}
        </style>
        <script type="text/javascript">
	jQuery('div.woocommerce').on('change', 'input.qty', function(){
	     jQuery("[name='update_cart']").removeAttr('disabled').attr('aria-disabled','false').trigger("click");
});
       </script>
	<?php

	}
}
Comment

update cart subtotal woocommerce

add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 10, 1);
function add_custom_price( $cart_object ) {

    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
        return;

    foreach ( $cart_object->get_cart() as $cart_item ) {
        ## Price calculation ##
        $price = $cart_item['data']->price * 12;

        ## Set the price with WooCommerce compatibility ##
        if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
            $cart_item['data']->price = $price; // Before WC 3.0
        } else {
            $cart_item['data']->set_price( $price ); // WC 3.0+
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel eloquent duplicate record 
Php :: php rearrange array 
Php :: php check if user exists in database 
Php :: substr php 
Php :: How do I get a YouTube video thumbnail from the YouTube API? 
Php :: wordpress - php settings 
Php :: jquery is less than or equal to 
Php :: php curl detect 404 
Php :: how to redirect to another page in php automatic after 2 second 
Php :: laravel sharing record 
Php :: if is page woocommerce 
Php :: laravel 9 route group 
Php :: last insert id mysqli 
Php :: import data from csv to db php 
Php :: keep line breaks in textarea 
Php :: preg_split in php 
Php :: laravel url with parameters blade 
Php :: laravel eloquent update multiple records 
Php :: use php artisan command through controller 
Php :: laravel validation exists array 
Php :: how do i know if file is empty in php 
Php :: which programming languae does php resemble to? 
Php :: laravel faker 
Php :: laravel valet subdomain 
Php :: php switch case statement 
Php :: upgrade php version to 7.4 or higher 
Php :: wp-config.php 
Php :: add contact form 7 to page templat e 
Php :: add floater to open a modal in wordpress 
Php :: php order array 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =