• Resolved costas96

    (@costas96)


    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 you

    add_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();
       " );
    
    }
    • This topic was modified 3 years, 9 months ago by costas96.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Since we haven’t had any input in a while, I’m going to go ahead and set this to resolved. I’d suggest taking a look at the links above or opening a new thread if you have a different question. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Total count of price at single product page based on two counter boxes’ is closed to new replies.