Jump to content
  • 0

Need to Add Dollar sign on this script


Saadkhanani1
 Share

Question

Can any buddy help me i need to add $ symbol on product_price and sub_total..

 

 

<script>
$( document ).ready(function() {    

    $(document).on("input paste keyup", ".product_qty", function( event ) {         
        
        var product_quantity = 0;
        var product_price = 0;
        var gst_amount = 0;
        var sub_total = 0;
        var total_qty = 0; 
        var grand_total = 0

        product_quantity = $(this).val();
        product_price = $(this).parent().prev().html();

        sub_total = product_price * product_quantity;

        $(this).parent().next().html(sub_total);


        $('.product_qty' ).each( function( k, v ) {
            product_quantity = parseInt ( $(this).val() ) ? parseInt ( $(this).val() ) : 0;
            product_price = parseFloat($(this).parent().prev().html())?parseFloat($(this).parent().prev().html()):0;

            console.log(product_quantity);
            console.log(product_price);            

            sub_total = parseFloat ( product_price * product_quantity );

            console.log(sub_total);

            total_qty +=product_quantity;

            grand_total += sub_total;

        });

        if ( grand_total > 0 ){
            gst_amount = ( grand_total * 6 ) /100;
        }
         
        $("#total_qty").html(total_qty);        
        $("#total_amount").html(grand_total);        

        grand_total +=gst_amount;

        $("#gst_amount").html(gst_amount);        
        $("#discount_amount").html(0);        
        $("#grand_total").html(grand_total);  
      
    });
    //
    $(document).on("click", ".delete", function( event ) {
        
        var cart_item = 0;
        $(this).parent().parent().remove();

        cart_item = $('.product_qty').length;
        if ( cart_item <= 0 ) 
        {
            $("#total_qty").html('0');        
            $("#total_amount").html('0');        
            $("#gst_amount").html('0');        
            $("#discount_amount").html(0);        
            $("#grand_total").html('0');             
        } else {
            $('.product_qty').trigger('keyup');  
        }      
        
    }); 
    
    
});

</script>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...