Debugging Validation Issues & Errors

How can I debug validation errors?
I have a situation where a name with an ampersand or quotes is not validating.
Hoe can I tell what the cause of this would be?

Here is my snippet:

$the_title = htmlspecialchars_decode("Coobie Camisole with Lace & Padding");
$input_name = '<input type="hidden" name="name'.get_verification('name', $the_title, $code).'" value="'.htmlspecialchars($the_title).'" />';

function get_verification($var_name, $var_value, $var_code, $mode = 'dev') {

$www_key = 'mykey';
$dev_key = 'mydevkey';
$api_key = ($mode == 'dev') ? $dev_key : $www_key;
$encodingval = htmlspecialchars($var_code) . htmlspecialchars($var_name) . htmlspecialchars($var_value);

return '||'.hash_hmac('sha256', $encodingval, $api_key).($var_value == "--OPEN--" ? "||open" : "");

I am trying to find the right combination for special characters. Since my CMS parses them first into html encoded characters, a second pass seems to make things worse, especially for ampersands where end up as &amp;

The passed URL for adding an item is:||9e596c36ac9977bb2889056976f5b7194246a32491ae33edb8b69d05faace524=Coobie+Camisole+with+Lace+%26+Padding&price||f16c2ff2d544cebe7963e6a42716a16fbf3e923b539101bc2db2f335adfb0d3d=24.00&code||5d94fbbc4d6a25d1b1f4f76092105803f5f9bfc0ca33ec37ef0dc5ec8fccc0cc=12431&quantity||a54e5805cd941652720be6f4e1d6a2ad81e653b5ee333a0b12673ddfa24e9b87=1&image||ace9e356419e85b9f814859460a9ade9ebe5b5bc63a2c781ed8cca317152d611=%2Fsites%2Fcoobie%2Fcache%2Fmedium%2F349500.jpg&color||898776ef8f44af5ec2802fc2116609b6c9ebf7d75ffaf85bbe3661771e7f60be=Charcoal%7Bc%2B008%7Cp%2B0%7D&fcsid=gveshehb4m067lb6tg2lk2fvm2

Any ideas why this isn't validating?
  • Aargh. I figured out what I was doing.
    It was working but i had a separate mobile file that wasn't updated, so it only was working on desktop devices an not mobile.
  • fc_adamfc_adam FoxyCart Team

    Glad you found a solution! Unfortunately we don't have a way to describe what about the encryption isn't working - the closest we can get you is to say which parameters are failing.
  • richtestanirichtestani Member
    edited July 2016
    @fc_adam On my end, the confusion was in a few places. 1) Names was being encoded with htmlspecialchars twice so & would end up as &amp; which would cause validation error. Double quotes were causing issues where I had value="My "Cool" Item" and was not encoded properly. So these were my major issues which I worked out. Thanks for responding!
  • richtestanirichtestani Member
    edited July 2016
    @fc_adam - continuing this conversation - I do have another issue if it's possible to debug.
    Sometimes on our site, the first time an item gets added to the cart, it does not get added - though my logs show the URL was sent. Adding it again is successful. I cannot find why this is happening. I will whisper my log, if you don't mind taking a look if you seen any oddities.
  • fc_adamfc_adam FoxyCart Team

    From your logs, it looks like the first add to cart is becoming a cart view instead? Would it be possible for me to see the actual add to cart page? That'd let me debug more thoroughly
Sign In or Register to comment.