Forum

Thread tagged as: Error, Shop

Perch Shop - Free Shipping Over X Promotion Not Working

Hi Guys,

I'm trying to create an automatic "Free Shipping over £50" promotion in Perch Shop.

So far, it's not working - if I create the promotion, and select the Shipping Method that it applies to, I get this error onscreen:


Warning: trim() expects parameter 1 to be string, array given in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php on line 139 Warning: PDO::quote() expects parameter 1 to be string, array given in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/lib/PerchDB_MySQL.class.php on line 382 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php:139) in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/lib/PerchUtil.class.php on line 1210 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php:139) in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/lib/PerchUtil.class.php on line 1211 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php:139) in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/lib/PerchUtil.class.php on line 1212 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php:139) in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/lib/PerchUtil.class.php on line 1218 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php:139) in /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/inc/top.php on line 17

and this in the debug:

Invalid query: SQLSTATE[42000]: Syntax error or access violation: 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 'AND shippingDeleted IS NULL LIMIT 1' at line 1

If I save the promotion without selecting the shipping method that it applies to, I don't get any errors. However, obviously that doesn't work for the promotion.

Here's my diagnostics:

Perch Runway: 2.8.29, PHP: 7.0.6, MySQL: 5.5.53, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_forms (1.8.3), perch_blog (5.0), perch_shop_orders (1.0.4), perch_shop_products (1.0.4), perch_shop (1.0.4), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_members', 'perch_shop', 'perch_forms' ); ?>
PERCH_LOGINPATH: /cms
PERCH_PATH: /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms
PERCH_CORE: /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core
PERCH_RESFILEPATH: /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/resources
Image manipulation: GD
PHP limits: Max upload 99M, Max POST 99M, Memory: 99M, Total max file upload: 99M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: staging.flykartel.com
DOCUMENT_ROOT: /home/198028/domains/staging.flykartel.com/html
REQUEST_URI: /cms/core/settings/diagnostics/
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php

Thanks, Harry

Harry Ray

Harry Ray 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Invalid query: SQLSTATE[42000]: Syntax error or access violation: 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 'AND shippingDeleted IS NULL LIMIT 1' at line 1

Above that line should be the query it's complaining about. If you could let me know what that is that would be helpful.

Hi Drew,

It looks as though the shipping method I've ticked hasn't been assigned an ID?

This is the preceding line:

SELECT * FROM perch2_shop_shippings WHERE shippingID= AND shippingDeleted IS NULL LIMIT 1
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you able to editing your shipping methods?

Hi Drew,

I'm able to edit the shipping methods that are in use without any issues.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So it sounds like your shipping methods do have IDs.

Yep, just checked the debug on the Shipping screen and this method has a shippingID of 1.

Any ideas as to the problem here, then?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Where is the error occurring?

Hi Drew,

I'm trying to create an automatic "Free Shipping over £50" promotion in Perch Shop.

The error occurs when I create/edit the promotion, and select the Shipping Method that it applies to.

Here is the error I get, and the last query just before that:

SELECT * FROM perch2_shop_shippings WHERE shippingID= AND shippingDeleted IS NULL LIMIT 1

Invalid query: SQLSTATE[42000]: Syntax error or access violation: 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 'AND shippingDeleted IS NULL LIMIT 1' at line 1
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the full debug?

This is the debug message that appears after trying to save a promotion that applies to a selected shipping method.

Debug Message
[1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=2 AND u.userHash='a7cba9d77d885533045951697cacacfe' LIMIT 1
UPDATE perch2_users SET userHash='acbe46bff58a035ebbe4267b2e63ca07' WHERE userID='2'
[41] SELECT p.privKey FROM perch2_user_privileges p
[32] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=2 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID
[nil] SELECT collectionID, collectionKey, collectionEditRoles FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
[1] SELECT * FROM perch2_shop_promotions WHERE promoID='8' LIMIT 1
Using template: /templates/shop/promotions/promotion.html
[2] SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=47 DESC, currencyCode
[2] SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=47 DESC, currencyCode
[2] SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=47 DESC, currencyCode
UPDATE perch2_shop_promotions SET promoDynamicFields='{\"title\":\"FREE SHIPPING OVER FIFTY\",\"description\":{\"_flang\":\"markdown\",\"raw\":\"Free Shipping on all orders over \\u00a350!\",\"processed\":\"<p>Free Shipping on all orders over \\u00a350!<\\/p>\"},\"from\":\"2016-03-16 15:20:00\",\"to\":\"2018-03-16 15:20:00\",\"active\":\"1\",\"action\":\"free_ship\",\"discount_code\":\"FREEOVER50\",\"amount_percent\":null,\"amount\":{\"47\":\"\",\"142\":\"\"},\"trigger_value\":{\"47\":\"50\",\"142\":\"50\"},\"max_discount\":{\"47\":\"\",\"142\":\"\"},\"max_uses\":null,\"customer_uses\":null,\"terminating\":\"0\",\"persistent\":\"1\",\"priority\":\"1\",\"apply_to_shipping\":\"1\",\"shipping_methods\":[\"1\"]}', promoTitle='FREE SHIPPING OVER FIFTY', promoFrom='2016-03-16 15:20:00', promoTo='2018-03-16 15:20:00', promoUpdated='2017-03-21 08:53:54' WHERE promoID='8'
No ids to log.
DELETE FROM perch2_shop_index WHERE itemKey='promoID' AND itemID='8'
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=142 LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=142 LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=142 LIMIT 1
SELECT * FROM perch2_shop_shippings WHERE shippingID= AND shippingDeleted IS NULL LIMIT 1
Invalid query: SQLSTATE[42000]: Syntax error or access violation: 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 'AND shippingDeleted IS NULL LIMIT 1' at line 1
INSERT INTO perch2_shop_index (itemKey, itemID, indexKey, indexValue) VALUES ('promoID',8,'title','FREE SHIPPING OVER FIFTY'),('promoID',8,'description','Free Shipping on all orders over £50!'),('promoID',8,'from','2016-03-16 15:20:00'),('promoID',8,'to','2018-03-16 15:20:00'),('promoID',8,'active','1'),('promoID',8,'action','free_ship'),('promoID',8,'discount_code','FREEOVER50'),('promoID',8,'amount_percent',''),('promoID',8,'amount',''),('promoID',8,'amount.gbp',''),('promoID',8,'amount.usd',''),('promoID',8,'trigger_value','50'),('promoID',8,'trigger_value.gbp','50'),('promoID',8,'trigger_value.usd','50'),('promoID',8,'max_discount',''),('promoID',8,'max_discount.gbp',''),('promoID',8,'max_discount.usd',''),('promoID',8,'max_uses',''),('promoID',8,'customer_uses',''),('promoID',8,'terminating','0'),('promoID',8,'persistent','1'),('promoID',8,'priority','1'),('promoID',8,'apply_to_shipping','1'),('promoID',8,'shipping_methods',''),('promoID',8,'promoID','8'),('promoID',8,'promoTitle','FREE SHIPPING OVER FIFTY'),('promoID',8,'promoFrom','2016-03-16 15:20:00'),('promoID',8,'promoTo','2018-03-16 15:20:00'),('promoID',8,'promoActive','1'),('promoID',8,'promoOrder','1'),('promoID',8,'promoCreated','2017-03-16 15:24:03'),('promoID',8,'promoUpdated','2017-03-21 08:53:54'),('promoID',8,'promoDeleted',''),('promoID',8,'itemID',''),('promoID',8,'itemRowID',''),('promoID',8,'_id',8)
[1] OPTIMIZE TABLE perch2_shop_index
[2] SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=47 DESC, currencyCode
[2] SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=47 DESC, currencyCode
[2] SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=47 DESC, currencyCode
[1] SELECT * FROM perch2_shop_shippings WHERE 1=1 AND shippingDeleted IS NULL ORDER BY shippingTitle ASC
Queries: 26
Memory: 3.7393
Array
(
    [type] => 2
    [message] => Cannot modify header information - headers already sent by (output started at /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/addons/apps/perch_shop/fieldtypes.php:139)
    [file] => /nfs/c11/h04/mnt/198028/domains/staging.flykartel.com/html/cms/core/inc/top.php
    [line] => 17
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

You're on a very old version of Shop. Is there a reason you can't update?