“Aktualisieren Sie WooCommerce Cart” Code-Antworten

Aktualisieren Sie 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

	}
}
Filthy Falcon

Aktualisieren Sie den 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+
        }
    }
}
Victorious Vole

Ähnliche Antworten wie “Aktualisieren Sie WooCommerce Cart”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen