I would like the following code to appear/work only if WooCommerce product quantity (in the product page)- is more than 1
/**
-
@snippet Calculate Subtotal Based on Quantity - WooCommerce Single Product
-
@how-to Get CustomizeWoo.com FREE
-
@author Rodolfo Melogli
-
@compatible WooCommerce 4.1
-
@donate $9 https://businessbloomer.com/bloomer-armada/ */
add_action( 'woocommerce_after_add_to_cart_button', 'bbloomer_product_price_recalculate' ); function bbloomer_product_price_recalculate() { global $product; echo '<div id="subtot" style="display:inline-block;">Total: <span></span></div>'; $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); $('#subtot > span').html('" . esc_js( $currency ) . "'+price_string); }).change(); " );
}
source https://stackoverflow.com/questions/68154425/woo-commerce-quantity-conditional-statement
Comments
Post a Comment