Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    23
    Plugin Contributions
    0

    Default Length calculator???

    I have a product of fence screen that has price by foot.
    The customer has to add the length in feet and inches into a text box and when they hit submit it must be figured into the price output.
    Is there a module that might do this?

    Also they must be able to add new sections of length.

    All this was working on a previous site before I took it over and it seems to be using this code. Does anyone know what module this might be? How would I set it up? (all the old files are still on the old server which I have access to, but I can't seem to figure which go to what.)
    Thanks in advance.
    ---------------------------------------------------
    (this was in head)
    <script type="text/javascript" language="javascript">
    var optionPrices = new Array();
    $(document).ready(function () {
    $('#attrib-10-0').parent().parent().hide();
    $('#attrib-8-31').parent().parent().hide();
    $('#attrib-6-0').parent().parent().hide();
    var productsId = $('#productsId').val();
    $('#addSectionLink').click(function(){
    var nextSection = parseInt($('#totalSections').val()) + 1;
    $('#totalSections').val(nextSection);
    $('#fenceSections').append('<tr class="widthEntry"><td><input type="text" name="widthFeet['+nextSection+']" size="3" onkeyup="calculateTotal()" class="widthFeet" /></td><td><input type="text" name="widthInches['+nextSection+']" size="3" onkeyup="calculateTotal()" class="widthInches" /></td></tr>');
    });
    $('.wrapperAttribsOptions').find("select").each(function() {
    $(this).change( function () {calculateTotal();} );

    $('option', $(this)).each(function(){
    // loop thru options
    var optionValue = $(this).val();
    $.get("ajax.php", { action: 'get.option.price',
    products_id: productsId,
    options_values_id: optionValue },
    function(data, textStatus){
    if (data['price'] != undefined) {
    optionPrices[data['options_values_id']] = parseFloat(data['price']);
    }
    },'json');
    });
    });
    });

    function calculateTotal() {
    var pricePerFoot = parseFloat(optionPrices[$('#attrib-9').val()]);
    var totalFeet = 0;
    var cutChargeAdded = false;
    $('#total').val('0.00');
    $('#totalLength').val('0');
    $('#customCut').val(0);
    $('#customCutText').hide();
    $('.widthFeet').each(function(){
    if ($(this).val() != '') {
    var currentTotal = parseFloat($('#total').val());
    var currentLength = parseInt($('#totalLength').val());
    if (parseInt($(this).val()) % 50 != 0) {
    if (cutChargeAdded == false) { cutChargeAdded = true; currentTotal += 20; }
    $('#customCutText').show(); $('#customCut').val(1);
    }
    var newTotal = currentTotal + parseFloat(pricePerFoot * parseInt($(this).val()));
    var newLength = currentLength + (parseInt($(this).val())*12);
    //alert(pricePerFoot + ': ' + currentTotal + ': ' + newTotal);
    $('#totalText').text(newTotal.toFixed(2));
    $('#total').val(newTotal.toFixed(2));
    $('#totalLength').val(newLength);
    $('#attrib-6-0').val(newLength+'in');
    }
    });
    $('.widthInches').each(function(){
    if ($(this).val() != '') {
    $('#customCutText').show();
    $('#customCut').val(1);
    var currentTotal = parseFloat($('#total').val());
    var currentLength = parseInt($('#totalLength').val());
    if (cutChargeAdded == false) { cutChargeAdded = true; currentTotal += 20; }
    var newTotal = currentTotal + parseFloat((pricePerFoot/12) * parseInt($(this).val()));
    var newLength = currentLength + (parseInt($(this).val()));
    $('#totalText').text(newTotal.toFixed(2));
    $('#total').val(newTotal.toFixed(2));
    $('#totalLength').val(newLength);

    }
    });

    $('#attrib-6-0').val('');
    $('.widthEntry').each(function(){
    var curTxt = $('#attrib-6-0').val();
    curTxt += $('.widthFeet',this).val()+'FT '+$('.widthInches',this).val()+'IN, ';
    $('#attrib-6-0').val(curTxt);
    });
    }
    </script>
    -------------------------------------------------------
    (this in body)

    <div class="wrapperAttribsOptions">
    <h4 class="optionName back">Length Options</h4>
    <div class="back">
    <input type="radio" name="id[8]" value="31" id="attrib-8-31" /><label class="attribsRadioButton zero" for="attrib-8-31">Custom Length - Cut Charge ( $20.00 )</label><br />
    <input type="radio" name="id[8]" value="32" id="attrib-8-32" /><label class="attribsRadioButton zero" for="attrib-8-32">Standard 50' Rolls - No Cut Charge</label><br />

    </div>
    <br class="clearBoth" />
    </div>





    <br class="clearBoth" />




    </div><div id="lengthname">Enter Your Fencing Widths</div>
    <div id="lengthdescription">Enter the feet and inches of each section you require for your project. You can add as many new sections as you need. </div>
    <input type="hidden" name="totalSections" id="totalSections" value="1" />
    <input type="hidden" name="totalLength" id="totalLength" value="0" />
    <table id="fenceSections">
    <tr><td>Feet</td><td>Inches</td></tr>
    <tr class="widthEntry"><td><input type="text" name="widthFeet[1]" size="3" onkeyup="javascript:calculateTotal()" class="widthFeet" /></td><td><input type="text" name="widthInches[1]" size="3" onkeyup="javascript:calculateTotal()" class="widthInches" /></td></tr>
    </table>
    <a href="#" onclick="return false;" id="addSectionLink"><u>click here to add a new section</u></a>
    <br /><br />

    <span id="customCutText" style="display:none;">Custom Cut Charge: $20.00<br /></span>
    <input type="hidden" name="customCut" value="0" id="customCut" />

    <b>Total Price: $<span id="totalText">0.00</span></b>
    <input type="hidden" name="total" value="0.00" id="total" />
    <br />
    <br />
    <!--eof Attributes Module -->


    <!--bof Quantity Discounts table -->
    <!--eof Quantity Discounts table -->


    <div id="cartAdd">
    <input type="hidden" name="cart_quantity" value="1" /><input type="hidden" name="products_id" value="87" id="productsId" /><input type="image" src="includes/templates/eprivacy/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " /> </div>
    <!--eof Add to Cart Box-->

    </div>

  2. #2
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    9,955
    Plugin Contributions
    3

    Default Re: Length calculator???

    I know that Scott Wilson (SWGUY) has worked on things like this. He's probably the best person to deal with your request.
    Our latest project is Pet Tags.

 

 

Similar Threads

  1. v139h Shipping Calculator
    By aditya369 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 3 Feb 2012, 10:51 AM
  2. Product calculator
    By kasia in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 3 Dec 2009, 03:11 PM
  3. Shipping Calculator
    By Kalebsands in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 7 May 2009, 09:08 PM
  4. Distance Calculator?
    By Astarkley in forum General Questions
    Replies: 0
    Last Post: 23 Nov 2007, 11:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •