The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Custom Order Entry and Cart Validation Errors

webmalamawebmalama Member
in Help edited April 2012
I have a client who would like to be able to enter custom orders to accommodate personally negotiated prices, quanities, shipping costs etc.

We had this set up prior to 7.? using UOE and a form I created where she could simply enter the Name, quanity, price per item, total shipping, total handling, and total tax. These were all just text input fields in a form that added it to a cart as separate items, giving total control.
<form action="https://removedforprivacy.foxycart.com/cart"; method="post" accept-charset="utf-8">
				<input type="hidden" name="code" value="manualentry" />
				<input type="hidden" name="category" value="manual" />
				<table border=0>
					<tr>
						<td>Item</td>
						<td>
							<input type="text" name="name" value="" id="name">
						</td>
					</tr>
					<tr>
						<td>Quantity</td>
						<td>
							<input type="text" name="quantity" value="1" id="quantity" />
						</td>
					</tr>
					<tr>
						<td>Price Per Item</td>
						<td>
							<input type="text" name="price" id="price" value="0" />							
						</td>
					</tr>
					<tr>
						<td>Total Shipping</td>
						<td>
							<input type="hidden" name="2:name" value="Shipping" />
							<input type="text" name="2:price" value="0" id="shipping"  />
							<input type="hidden" name="2:category" value="manual" />
						</td>
					</tr>
					<tr>
						<td>Total Handling</td>
						<td>
							<input type="hidden" name="3:name" value="Handling" />
							<input type="text" name="3:price" value="0" id="handling" />
							<input type="hidden" name="3:category" value="manual" />
						</td>
					</tr>
					<tr>
						<td>Total Tax</td>
						<td>
							<input type="hidden" name="4:name" value="Tax" />
							<input type="text" name="4:price" value="0" id="tax" />
							<input type="hidden" name="4:category" value="manual" />
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
							<input type="submit" value="Add to Cart" />
							<input type="hidden" name="h:custom_order" value="yes" />
						</td>
					</tr>
				</table>
			</form>

Since our recent update from 0.60, this is now getting errors. I'm guessing this has to do with your new security measures and encoding values. If so, is this method still possible? If not, what is the best way to accommodate her need for custom orders?

The errors received are:
Cart Validation Error: price
Cart Validation Error: 2:name_hash_present
Cart Validation Error: 2:price_hash_present
Cart Validation Error: 2:category_hash_present
Cart Validation Error: 3:name_hash_present
Cart Validation Error: 3:price_hash_present
Cart Validation Error: 3:category_hash_present
Cart Validation Error: 4:name_hash_present
Cart Validation Error: 4:price_hash_present
Cart Validation Error: 4:category_hash_present

Tagged:
Comments
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    The easiest way to solve this would be to turn off the cart validation option on the FoxyCart advanced tab. Would that work?
  • fc_adamfc_adam FoxyCart Team
    @webmalama,

    It is still possible, but you need to encode the form to allow it to be validated like you have for your other forms.

    If you take your form you've pasted above, and in the sample code section of the admin paste it into "Step 2", then hit "encode html" it will encrypt your form. Then you can just paste that back into your page and you should be good to go. Note that if you want the field to be editable by you, you'll need to leave the value for the fields blank.
  • @sparkweb, the rest of the site where 'standard' customers go uses the validation so we'd like to keep it there if possible, good thought though.

    @fc_adam, Thanks, it appears that leaving the field value blank was the sticking issue. Now I'm only receiving errors for those fields that weren't encrypted by the "Step 2" encrypt form, which are those that have a name value starting with a number, like "2:name" or "3:price". Is there a way I can manually encrypt these? Or, is there a better way to add those items that doesn't involve starting the name with a number?
  • fc_adamfc_adam FoxyCart Team
    @webmalama,

    That's the one :) So you can simply remove the prefixes when you encrypt it, and then re-add them after encryption.
  • webmalamawebmalama Member
    edited April 2012
    Hmm, I followed the process of removing the prefix, encrypting the form, and then adding back in the prefix.

    A Before (for example):
    <input type="hidden" name="4:category value="manual" />
    

    With Removed Prefix:
    <input type="hidden" name="category value="manual" />
    

    After Encryption:
    <input type="hidden" name="category||d1641f374a680d3f98459e2c9b896161a1314859c734ba495958581c9823d447" value="manual" />
    

    With prefix added back in:
    <input type="hidden" name="4:category||d1641f374a680d3f98459e2c9b896161a1314859c734ba495958581c9823d447" value="manual" />
    

    I now have the following error for all items with a numeric prefix (just one given here using the example code above):

    Cart Validation Error: 4:category

    Thoughts?

  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    You could try putting ||open at the of the validation string to indicate that the validation should be ignored.
  • fc_adamfc_adam FoxyCart Team
    @webmalama,

    Ok - my bad. I got a bit confused.

    So what you need to do is leave the number prefixes in your form, but also add a code parameter for each of those products as well. The signing requires that each product has a code parameter set as well.

    Give that a try.
  • @fc_adam, When I tried adding the codes this morning I noticed that the manual encoder on sample code page is now encoding both form elements without and with a name starting with a number (prefix). Perhaps something changed yesterday in the encoder? (Or perhaps something in my code was corrected this morning?)

    So, I was able to simply add an item code for each of the items (code, 2:code, 3:code, 4:code) into my original form, paste this into the encoder, and use the end result. (As opposed to first removing prefixes, encoding, and then adding prefixes back in).

    It's now up and running as expected.

    Thanks!
  • fc_adamfc_adam FoxyCart Team
    @webmalama,

    Nothing changed with the hmac code, it related to having the 'code' parameter for each product in your form setup.

    Glad it's working for you now.
Sign In or Register to comment.