Avec le code ci-dessous lorsque l’acheteur choisira une quantité supérieure à 1, Le total vas s’afficher à côté du bouton « Ajouter au Panier », l’acheteur sera immédiatement le prix total sans avoir à ensuite se référer à la page Panier.
/** * @author Naxialis * @tester WooCommerce 6.3.1 * @url https://naxialis.com */ add_action( 'woocommerce_after_add_to_cart_button', 'naxialis_product_price_recalculate' ); function naxialis_product_price_recalculate() { global $product; echo 'Total:'; $price = $product->get_price(); $currency = get_woocommerce_currency_symbol(); wc_enqueue_js( " $('[name=quantity]').on('input change', function() { var qty = $(this).val(); var price = '" . esc_js( $price ) . "'; var price_string = (price*qty).toFixed(2).replace(".", ","); $('#subtot > span').html(price_string+' " . esc_js( $currency ) . "'); }).change(); " ); }