Is it possible to use a form for variable pricing with HMAC encoding?

ChubbRckChubbRck Member
in Help edited June 2013
Hi there,

I have a form created for a gift certificate... the customer can determine the price by changing the number in a 'number' field. Unfortunately, it doesn't work once I've manually HMAC encoded the form, which makes sense because the default price has been changed and no longer matches the hash. Is there a smarter way to approach this? Any advice is appreciated, thank you!
  • winstonwinston FoxyCart Team

    In the case of user-editable inputs like a gift certificate value field, you'll need to mark the field as "Open" for HMAC encoding. See here for more information. Specifically, in the input's name attribute you'll want to make sure the last argument is ||open and that the server-side code adds the flag --OPEN-- to the second argument of the hash_hmac() function.

    Let us know if you have further questions!
  • Hey Winston, thanks so much for your help - of course, I should have recalled marking the field as 'open' as Adam mentioned that in another thread.

    One question though - I'm actually not using server-side encoding, but rather encoding my links manually. Is it still possible to mark a field as open using this method, and if so, how?

    Thanks for your help -

  • winstonwinston FoxyCart Team

    How are you going about manually encoding links?
  • I'm using the 'sample code' section of the foxycart UI
  • Copying and pasting into it, that is
  • fc_adamfc_adam FoxyCart Team

    So just to clarify, you're wanting to add an open attribute to a link, or to a form?
  • Sorry, in this case it is a form - thank you guys for the help.
  • fc_adamfc_adam FoxyCart Team

    If you simply leave the input value blank, it'll be marked as an open field.
  • Hmm... I tried your suggestion, Adam, but I still get an error that the price field is not validated. Forgive me if I'm missing something dumb, forms are not my forte.

    Here's my code for the price input:

    <input type="number" size="3" name="price||abf18e208db341f606b49f330b754d35f2604d00dbf6a18dad7fd24e9dd249e5" min="10" max="999">

    I took out the 'value' field but no dice. I also tried setting the value to "".
  • Looks like I spoke to soon, I must have made a mistake while encoding my links because now it is working great.

    Thank you again, you guys are rad.
  • fc_adamfc_adam FoxyCart Team

    Yeah, when you encrypt the field, you need to leave a blank value attribute in there like this:
    <input type="number" name="price" value="" />

    Sorry for not making that clear earlier. Glad you got it sorted.
Sign In or Register to comment.