Give each of your form inputs an ID using the Item / Extended dialog
or the Classify Action, and apply Protaculous to the page so you get
all the Prototype niceties. Let’s assume you have given them the
following: length, width, and total_cost.
Click on the top Function Body button in Protaculous, and paste in the
following:
var f = $(document.forms[0]);
var updater = function(elm,values){
vars = values.toQueryParams();
$('total_cost').setValue(
(Math.round(
vars['length'] *
vars['width'] *
40 * 100) / 100).toFixed(2));
}
new Form.Observer(f,0.3,updater);
This makes the following assumptions:
- You have only one form on your page.
- You have set the form fields to have precisely these IDs (and
Freeway doesn’t set IDs on form fields by itself, so you have done
this step by hand or by Action).
- Your Pounds per square meter number is 40 (set in the 8th line).
When I enter the dimensions you noted, I get the price you quoted.
So this gives you a price for the dimensions. But you need to send the
square meters number back to your cart. If you know the name of that
form element (and have set an ID on it as well) then you can extend
the function above to read like this:
var f = $(document.forms[0]);
var updater = function(elm,values){
vars = values.toQueryParams();
var area = vars['length'] * vars['width'];
$('total_cost').setValue(
(Math.round(area *
40 * 100) / 100).toFixed(2));
$('total_area').setValue(area);
}
new Form.Observer(f,0.3,updater);
In this example, I have given that form field the ID of total_area. So
this would pass the total area calculated back to the cart, along with
the height and width. The area would be multiplied by the price per
meter2 at the cart side of things, so you would have a double-check.
(Never accept the customer’s version of the total price!)
Walter
On May 14, 2010, at 1:36 PM, DillyDog wrote:
Hi All
I’m probably asking the impossible (again) but I have been posed
with a request from a client and I need to know if it is at all
possible with Freeway.
My client designs murals printed on wallpaper and his designs can be
printed at any size and priced per square metre.
When a customer chooses a design, they then enter the size they
require length x height. i.e. [2.4] x [1.7]
The script then has to calculate the area and multiply by the cost
per sq m, so if the cost per sq m is £40, the total cost would be
£163.20 and this then appears in the cost field before then adding
to the basket.
Deos anyone know of a way of doing this, especially using Mals-e.
As usual, any help and input is very much appreciated.
Cheers
Tim
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options