Total count of price at single product page based on two counter boxes
-
At single product page I have two counter boxes. One for amount of Terabytes and one for Quantity of the specific product. What I want is to take the values of these boxes and add them with the base price of the product.
For example if we have a Product A with price 54 and the customer increase the Terabytes box lets say by 2 I want 56 to be displayed at the Total count box.
Now lets say after thatm that the customer increases the Quantity box by 2. I would like 58 to be displayed as the Total count.
What I have achieved so far with the code below is taking the values from these two boxes but at the total count box the price doesn’t display profperly.
What I mean is that if I have let’s say the number 1 at each of the counter boxes we have Product A with price 54, 541 is displayed at the Total count box.
Below is my code, any suggestions would be appreceiated. Thank youadd_action( 'woocommerce_after_add_to_cart_button', 'bbloomer_product_price_recalculate' ); function bbloomer_product_price_recalculate() { global $product; echo '<div id="subtot" class="button single_add_to_cart_button button alt">Total: <span></span></div>'; $price = $product->get_price(); $currency = get_woocommerce_currency_symbol(); wc_enqueue_js( " $('[name=number-1620393141673],[name=quantity] ').on('input change', function() { var qty = $(this).val(); var price = '" . esc_js( $price ) . "'; var price_string = (price+qty); if(qty <= 5) { $('#subtot > span').html('" . esc_js( $currency ) . "'+price_string); } else { javascript:document.getElementById('subtot').innerHTML='<strong>Please contact us</strong>'; } }).change(); " ); }
The page I need help with: [log in to see the link]
- The topic ‘Total count of price at single product page based on two counter boxes’ is closed to new replies.