MySQL errors
Permalink Browser Info Environment
I am playing about with some ideas offline before implementing them on the site.
I have created a product that requires no delivery and is not a physical product.
http://www.awesomescreenshot.com/image/694607/c88f8c1475dae8240d8ae...
I add the product to a page using a product block and the 'select product' option. No callouts or overlays. Just a price, description and add to cart.
http://www.awesomescreenshot.com/image/694619/6c537994361432a7289fd...
Default view template
http://www.awesomescreenshot.com/image/694624/9f136a3a55351a0874093...
On clicking 'Add to cart' the AJAX hangs. In the developer console the response is a SQL error
The cart shows a product added, but it has a zero price:
http://www.awesomescreenshot.com/image/694683/eaaf97194124af81bc777...
The post data is
Exploring fixes, If I hack the Product::getByID() method, from
to
I now get a further error
I have created a product that requires no delivery and is not a physical product.
http://www.awesomescreenshot.com/image/694607/c88f8c1475dae8240d8ae...
I add the product to a page using a product block and the 'select product' option. No callouts or overlays. Just a price, description and add to cart.
http://www.awesomescreenshot.com/image/694619/6c537994361432a7289fd...
Default view template
http://www.awesomescreenshot.com/image/694624/9f136a3a55351a0874093...
On clicking 'Add to cart' the AJAX hangs. In the developer console the response is a SQL error
<h1>An unexpected error occurred.</h1> <div class="ccm-error block-message alert-message error">mysqli error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1] in EXECUTE("select productID, orderID, quantity, prPricePaid, prDiscount, prName from CoreCommerceOrderProducts where orderProductID = ?") </div><p><a href="http://localhost/ecosurety/cms2" class="btn">< Back to Home</a></p> </div>
The cart shows a product added, but it has a zero price:
http://www.awesomescreenshot.com/image/694683/eaaf97194124af81bc777...
The post data is
rcID:183 submit:Add to Cart productID:2 method:JSON
Exploring fixes, If I hack the Product::getByID() method, from
$row = $db->GetRow("select productID, orderID, quantity, prPricePaid, prDiscount, prName from CoreCommerceOrderProducts where orderProductID = ?", $orderProductID);
to
$row = $db->GetRow("select productID, orderID, quantity, prPricePaid, prDiscount, prName from CoreCommerceOrderProducts where orderProductID = ?", array($orderProductID));
I now get a further error
Fatal error: Call to a member function rescanOrderProductPricePaid() on a non-object in E:\web\ecosurety\cms2\packages\core_commerce\models\order\product.php on line 94
Type: | Discussion |
---|---|
Status: | In Progress |
I was logged in as admin while doing all of the above.
Allocating the product to a page and selecting 'Inherit from current page' makes no difference. Same errors.
This doesn't appear to happen on an existing site/installation on my dev system. Only on a newly installed site.
Never mind. Updating the fresh install to the latest eCommerce solved the problem.
But why did the existing eCommerce installation work OK on the same previous version? But not this installation?
But why did the existing eCommerce installation work OK on the same previous version? But not this installation?
I'm not sure why it wasn't working, but your original error makes it sound like `$orderProductID` is null where it shouldn't be. I'm glad to hear updating fixed the issue :)
I suspect that data somewhere was lax about differentiating between null, empty string and zero with SQL parameters. Perhaps relating to the first ever cart.