I’m building a multi-page form. The first page of the form uses a foreach loop to display products in a category. The shopper increases the quantities of the products that they want to add to the basket, and then hit continue. However, I’m not committing the items to the basket just yet, I’m just storing them in an array.
I’d like to have a “Back” button, so the shopper can have the opportunity to go back to the last page and adjust the quantities, and I’d like the quantity text fields to be auto-populated with the quantities that they’ve already selected, rather than them all being set back to zero. So when they click the “Back” button, I’m passing variables like: prod1=5, prod2=3, prod3=1, where the variable name is the Miva product ID, and the value is the quantity they’ve selected.
But now I’m stuck on auto-populating the quantity fields with those passed variables.
Logically, I think it needs to be something like this:
That would be placed within the foreach loop, and would create a variable of the current product named "CurrentID" with a value of prod1, prod2, prod3, etc...
Then I need to say:
IF a global variable exists with the same name as the value of g.CurrentID
{
set the quantity field to its value
} ELSE {
set the quantity field to zero
}
But, I cannot for the life of me figure out how to write this code. Or maybe I’m going about it the wrong way, altogether.
If anyone can assist me with this, I’d really appreciate it!
Thank you
I’d like to have a “Back” button, so the shopper can have the opportunity to go back to the last page and adjust the quantities, and I’d like the quantity text fields to be auto-populated with the quantities that they’ve already selected, rather than them all being set back to zero. So when they click the “Back” button, I’m passing variables like: prod1=5, prod2=3, prod3=1, where the variable name is the Miva product ID, and the value is the quantity they’ve selected.
But now I’m stuck on auto-populating the quantity fields with those passed variables.
Logically, I think it needs to be something like this:
Code:
<mvt:assign name=“l.settings:currentID" value="'prod' $ l.settings:product:id" />
Then I need to say:
IF a global variable exists with the same name as the value of g.CurrentID
{
set the quantity field to its value
} ELSE {
set the quantity field to zero
}
But, I cannot for the life of me figure out how to write this code. Or maybe I’m going about it the wrong way, altogether.
If anyone can assist me with this, I’d really appreciate it!
Thank you
Comment