Order Form

Hello, I’m trying to create an order form for my clients, I don’t want them to pay by the website.
I already have this:

The costumers can select a product. The image and price (Precio Unitario) change depending on the product selected and the quatity is an input from the costumer. What I want is a way that I can save the information choosen by the costumer so the “Monto Neto Total” get the sum between different selections of different products. And those selections get saved in the table below.

I would be gratefull if someone could help me.

Hi!

If moving between products requires moving to another page I’d suggest to use session storage in order to pass the total sum between the pages.
You can read about the Wix Storage API here .

If moving between products does not requires the user to move between pages id suggest to use a global variable that will store the total sum of the cart and use an event listener of ‘onChange’ (on the quantity field) to update your sum (either buy adding or subtracting from it).

Let me know if it works for you.

Doron.

Hi,

To move between pages is not required, so the second option it’s what I need, but I’m pretty new on Wix Code, and I have tried to use a global variable without success, could you give me an example of the code?

@catherine

If all the products are being selected on the same page and theres no navigation between pages you’ll need to use a few variables from your page, such as:
*Each item’s price
*Each item’s quantity

So your code would be something like this:

(Since you want to change the sum every time the user will change the quantity- we’ll use the event listener of “onChange” of the quantity text box and use also the text element of the price in order to calculate the sum to change.)

let item1Sum = 0;
let globalSum = 0;

export function quantityOfItem1_change (event, $w) {
if (item1Sum > 0){
globalSum = globalSum - item1Sum;
item1Sum = ($w(#item1Quantity).value * $w(#item1Price).value);

// If there's already selection that was changed again by the user - we want to eliminate it before updating the sum.

} else {
    item1Sum = ($w(#item1Quantity).value * $w(#item1Price).value);
    globalSum = globalSum + item1Sum ;
  }
}

Note that:
*While coding, all the field’s names need to match the actual names of the components in order to be able to address the correct item and the right value.
*This bit of code is an example for a single product use in your page, if you have more than one item selection in your page - you’ll need more events like that or alternatively a more dynamic code.

If you want me to give you more guide lines regarding what you need in your page code please elaborate on the structure of your page.

Please note that in this forum , us the moderators, are here to help you learn by providing examples, articles and guides in order for you to gain tools to achieve your goals by yourself.

If you’re having trouble in coding I’d suggest you to seek help in the Wix Arena where you can hire a pro designer/developer to help you build your site.

Hope it helps,

Doron.