Support » Plugin: Shatner - Name your Own Price Integration for WooCommerce » Bug lets users easily get around it

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sparky672

    (@sparky672)

    I have not fixed this issue yet on my own, however, I have some serious concerns about the jQuery employed on the template…

    $('#price').clone().attr('type','hidden').appendTo($('form.cart'));

    This will clone the #price element, giving you two elements with the same id in the DOM. Most browsers’ JavaScript engines have nasty problems when you have two elements with the same id.

    Why clone this entire element when all we really need to do is copy the value?

    IMHO, the following method is safer, which creates a new hidden element with the proper value, rather than cloning something we don’t need…

    $('form.cart').append('<input type="hidden" name="price" id="price" value="' + $('#my-price').val() + '" />');

    I’ve also changed the id of the “name your price” field from price to my-price in order to remain HTML compliant, keep the two input elements unique, and avoid potential browser JavaScript issues.

    Plugin Author Sean Voss

    (@seanvoss)

    Sounds good sparky, not a problem whatsoever. Thanks for the code.

    Secondly, on your first part I just whipped up the change last night quickly for another user in the forum, I’ll do some testing on the JS and make sure to cover your test case.

    Cheers,

    Sean

    Plugin Author Sean Voss

    (@seanvoss)

    Alright Sparky, download 1.5 should have a whole basket of fixes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug lets users easily get around it’ is closed to new replies.