LOT Auctions - Prevent Mistakes

Details of modifications which users can incorporate within Enuuk Auction Platform free of charge
Post Reply
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

LOT Auctions - Prevent Mistakes

Post by RWAP » Fri Jan 08, 2010 12:40 pm

I have had a couple of users now, who purchased the entire LOT auction when they only meant to purchase one of the item.

* Updated to Take Account of v1.8 *

In order to prevent this, I would suggest two changes:
In themes\default\offerWantedLot.php
Slight change to wording:
Find:

Code: Select all

<strong><?=sprintf("%0.2f",$bid)?></strong> <?=$siteOptions['defaultCurrency']?> <?=_("each one") ?> 
Change this to:

Code: Select all

<strong><?=sprintf("%0.2f",$bid)?></strong> <?=$siteOptions['defaultCurrency']?> <?=_("each") ?> 
- the line which prompts the user to enter number required is made bold:

Code: Select all

                    <label class="c6">
                    <span><?= _('Quantity')?> : </span>
                        <input type="text" name="quantity" value="1" />
                    </label>
becomes:

Code: Select all

                    <strong>
                    <label class="c6">
                    <span><?= _('Quantity')?> : </span>
                    	<input type="text" name="quantity" value="1" />
                    </label>
                    </strong>

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: LOT Auctions - Prevent Mistakes

Post by RWAP » Fri Jan 08, 2010 12:41 pm

It would be nice to add a total order line on the form to confirm purchase - based on $quantity * $price - this would need to be in javascript as it would change as a new quantity is entered - anyone willing to put forward the code?

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: LOT Auctions - Prevent Mistakes

Post by RWAP » Sat Feb 06, 2010 8:33 am

Javascript required is set out below:

In the themes\default\offerWantedLot.php
Find:

Code: Select all

<? include_once "header.php" ?> 
Add below this:

Code: Select all

<script type="text/javascript">
/* Based on original script by Paul McFedries and
Logophilia Limited (http://www.mcfedries.com/).
Permission is granted to use this script as long as
this Copyright notice remains in place.*/

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString();

    // Locate the decimal point
    var decimal_location = value_string.indexOf(".");

    // Is there a decimal point?
    if (decimal_location == -1) {

        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0;

        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : "";
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1;
    }

    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length;

    if (pad_total > 0) {

        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) {
            value_string += "0";
        }
	}
    return value_string;
}

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals);
    var result2 = Math.round(result1);
    var result3 = result2 / Math.pow(10, decimals);
    return pad_with_zeros(result3, decimals);
}

function ReCalculateTotal(frm) {

    // Display the total rounded to two decimal places
    quantity=eval(frm.quantity.value);
    unitCost=eval(frm.bid.value);
    frm.TOTAL.value = round_decimals(quantity*unitCost, 2)+ ' <?=$siteOptions['defaultCurrency']?>';
}
</script>
Then find the amended lines above:

Code: Select all

                    <strong>
                    <label class="c6">
                    <span><?= _('Quantity')?> : </span>
                       <input type="text" name="quantity" value="1" />
                    </label>
                    </strong>
This becomes:

Code: Select all

                    <strong>
                    <label class="c6">
                    <span><?= _('Quantity')?> : </span>
                    	<input type="text" name="quantity" value="1" onchange="ReCalculateTotal(this.form)"/>
                    </label>
                    </strong>
                    <div class="clear"></div>
                    	<strong>
                        <label class="c6">
                        <span><?= _('Total Cost (excluding postage)')?> : </span>
                            <input type="text"  style="border-style:none;background-color:transparent" name="TOTAL" value="<?=sprintf("%0.2f",$bid).' '.$siteOptions['defaultCurrency']?>" readonly onfocus="this.blur()"/>
                        </label>
                        </strong>

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest