Error! The price validation failed.
-
Hi there. Upon updating to the latest version, clicking on any add to cart link gives the “Error! The price validation failed.” fatal error – whether I am logged in or not.
When I turn debug on, I don’t get anything in the error log file.
http://woodsbodygoods.com/thegoods/
Note: I initially updated because I was having a problem where only one item could be added to the cart at a time – when you add a new item, the earlier one disappears.
I fixed both issues above by rolling back to WP Simple Paypal 3.99.
https://ww.wp.xz.cn/plugins/wordpress-simple-paypal-shopping-cart/
-
Hi, I just carried out a test in one of my browsers and I don’t receive any errors.
I suspect that it is a cache related issue. Can you clear your browser cache. If you have a cache plugin can you also clear the plugin cache.
Regards
I just tested on your site and the buttons work fine. So I think it was a cache issue. Please do a test after erasing cache and confirm.
Hi there mra13,
I’ve re-updated to version 4.10 of the plugin, cleared the cache in three different browsers, and still get the error when I click “Add to Cart” on the http://woodsbodygoods.com/thegoods page.
Might it be a conflict with another plugin?
Or with the way the prices are entered in the custom field? Does the software expect a strict price value in the format of 00.00? What exactly is “price validation” doing?
Thanks again!
This shouldn’t be a conflict. There is an extra security check in the plugin to validate the price (so it can’t be tampered with). This check is failing on your site. When I interacted with your site yesterday, it definitely worked for me.
Just normal price value will work fine. I don’t think you are using the correct shortcode to generate the button. Which is why that validation is failing.
Enter the following shortcode on a test page and then share the URL of that test page so I can inspect a few things:
[wp_cart_button name=”Test Product” price=”19.95″]
Hey there mra13,
Here’s what I figured out that the issue is.
Embedding the shortcode normally in a page or post, normally, works:
[wp_cart_button name="Test Product" price="19.95"]But I don’t use the shortcode in the post. Because I’ve been using the plugin more programmatically, I’ve been using it to generate product listings and so on. So I have the site owner enter a price in a field, and I reproduce the form that the shortcode creates on the page in a loop to show products.
So the products are entered as a custom post type and a custom field holds the price – that gets stored in the variable $the_price and rendered.
That lets me create pages like this:
http://woodsbodygoods.com/thegoods/
http://woodsbodygoods.com/products/lip-shimmer/
(Note: Right now because the store is closed, I made the “Add to Cart” buttons that my code generated go away)When the plugin didn’t check for price validation, that used to work great.
So I’ve run some tests.
Just reproducing the form still works no problem, if I do this:
<p><strong>A great product</strong> ($29.95)</p> <div class="wp_cart_button_wrapper"> <form method="post" class="wp-cart-button-form" action="" style="display:inline" onsubmit="return ReadForm(this, true);" > <input type="submit" value="Add to Cart" /><input type="hidden" name="wspsc_product" value="Test Product" /> <input type="hidden" name="price" value="29.95" /><input type="hidden" name="shipping" value="0" /> <input type="hidden" name="addcart" value="1" /> <input type="hidden" name="cartLink" value="http://woodsbodygoods.com/test-page/" /> <input type="hidden" name="product_tmp" value="Test Product" /> <input type="hidden" name="item_number" value="" /> <input type="hidden" name="hash_one" value="a0709891fbffed660233b1bcf7f7a66f" /> </form> </div><!-- ends button-wrapper -->But because I need to move the price in there programmatically, I’ve added the first line and changed the second line in the form:
$the_price = 29.95;<input type="hidden" name="price" value="<?php echo $the_price; ?>" />As soon as I do this, the form renders okay, but I get the price validation failure when I click the add to cart button. Basically, replacing the hard coded value with a variable throws it.
As a different approach to this whole problem could work, I’ve also tried rendering the form using PHP’s do_shortcode command with [wp_cart_button name=”Test Product” price=”19.95″] in it, but it does not seem to work for me – nothing renders.
Any thoughts?
Thanks!
You just have to use this plugin’s function to generate the form otherwise the validation will fail.
The do_shortcode option should definitely work. You can also directly call the PHP function to render the button. Here is what you can use from your custom code (pass the name and price in that function):
<?php echo print_wp_cart_button_for_product($name, $price); ?>Awesome! This last way to do the code works for me. I’m not sure why do_shortcode doesn’t display anything for me, but as long as this alternative works, I’ll be fine. Thank you so much!
The topic ‘Error! The price validation failed.’ is closed to new replies.