WebSite X5Help Center

 
Cris I.
Cris I.
User

Input field in product option for free insert numbers  en

Auteur : Cris I.
Visité 2010, Followers 1, Partagé 0  

Hello everyone,


I want to create a shop that sell carpets and i want to give to the users the option of inserting the dimensions (or one dimension and the other would be fixed) that they want and then add the product(carpet) in the cart.

i made a simple script (see at the end) for calculating the square meters (m<sup>2</sup>) and the total price and show them into div. I want when pressing the buy button to take that price and dimension to the cart page and not the attributes that the product has.


Is there a way to intergrate with the cart object (take some data from the x5cart.js like the price, id, option or what else is necessary) or do i need custom code? can you help me with the custom code?


Thank you in advance.


Script code


$("input#area").change(function(){
var fixed_box = $('#fixed').val(); //here i want the option val from the x5cart.js of the product
var input_box = $('#area').val();
var priceFirst = 40; //here i want take the price from the x5cart.js of the product
var priceTotal = (fixed_box*(input_box/100));
if ( input_box != ''){
$("div#resultsq").html(priceTotal + " m<sup>2</sup>");
$('div#result').text(priceTotal*priceFirst);
}
else{
$("div#resultsq").html("Give the length in cm");
$("div#result").html("");
}
});

Html code


<input type="text" id="fixed" name="fixed" placeholder="Enter in square metres!" class="input" value="0.67" disabled/><br/>
<input type="text" id="area" name="area" placeholder="Enter in square metres!" class="input"/><br/>
<div id="resultsq"></div><br>
<div id="result"></div>

Posté le
3 RéPONSES - 1 UTILES
Cris I.
Cris I.
User
Auteur

Hi Riccardo,

Thank you for your answer. I found that url in my search for a possible solution, but because i am nube :P in coding the only thing that i can get from that link is that it can be done. Im trying by myself but i was wondering if there is any chance to have more help. Like a step by step guidance or guide :) ?

Thank you again

Lire plus
Posté le de Cris I.
Incomedia
Riccardo P.
Incomedia

Hello Cris,

unfortunately that is the only guide on this argument, if you do not understand, try to write a new topic asking more information about a specific function.
thank you

Lire plus
Posté le de Riccardo P.