I would like to make an attribute text field into a php variable.
Ideally the value the customer places in that field should be able to be retrived later on in the checkout process.
How do i best do this?
The attribute on my product page has an input name and the form is submited via POST then shouldn't I be able to call it back later on with $_POST["input name"]?
For example this simple form works in a test environment.
Code:
<form action="index.php" method="post">
<input type="text" name="attribute" />
<input type="Submit" name="Submit">
</form>
index.php
Code:
<?php $attrib = $_POST["attribute"]; ?>
Your Attribute value is <?php echo $attrib; ?>
However when I input this into the store it no longer works.
I tested this by modifying the product page to include an additional field
Code:
<input type="text" name="attribute" />
and modifying the next stage in the process, the shopping cart 'tpl_shopping_cart_default.php' with
Code:
<?php $attrib = $_POST["attribute"]; ?>
Your Attribute value is <?php echo $attrib; ?>
What happens is the shopping cart page only shows 'Your Attribute value is' and not the variable.
1. Why does this code work in a test environment and not in the store?
If we can get this to work then there will be one final hurdle. The attribute input name that Zen Cart uses is 'id[text_12]'
Whenever we need to retrieve the variable we couldn't use
Code:
<?php $attrib = $_POST["id[text_12]"]; ?>
Your Attribute value is <?php echo $attrib; ?>
since the square brackets aren't escaped. How do we do that? Can we use "\" somehow to escape the next characters?
Anyway, I'm probably getting ahead of myself. At this stage I have to get text field -> php variable working in zencart.
As always, I appreciate any help anyone can prove on the matter.
If i'm going about this the wrong way then feel free to correct me,
Thanks in advance,
Shaztesting
Bookmarks