Forum

Thread tagged as: Question, Runway, Shop

Perch Shop Order page

Hi,

I have a question regarding Perch Shop and customers viewing a single order.

I've seen this thread here, that definitely helps:

https://forum.grabaperch.com/forum/08-05-2016-displaying-individual-orders

But what I don't understand is where this code should go. Does it require the creation of an order page and then a sub-page with a specific name?

At the moment the links wrapped around the invoice name in the order list (using perch_shop_orders();) generates something like:

https://www.example.com/orders/39

But we cannot work out where to input code that is displayed on the "39"...

Any help is much appreciated!!

Regards, Alex

Alex Bennett

Alex Bennett 0 points

  • 4 years ago

Hi Alex

You need to create an orders page and call the order in the url with:

<?php perch_shop_order(perch_get('orderID')); ?>

Then create a route for that page with something like:

path-to-page/orders/[i:orderID]

Hope this helps,

Jon

Hi Jonathan,

Thanks for your reply - I've tried that, and yes, thank you, it definitely routes to the page I've now created.

Only problem is it's throwing an error after using:

<?php perch_shop_order(perch_get('orderID')); ?>

It says:

Fatal error: Call to a member function to_array() on boolean in /home/mysite/public_html/dev/perch/addons/apps/perch_shop/lib/PerchShop_Order.class.php on line 538

Does that mean anything to you?

Regards, Alex

Hmm. Not sure I'm afraid. You'd need to post your diagnostics.

Are you logged in (as a member) when trying to view the order?

Hi Jonathan,

Yes - I visited the page after clicking a linked wrapped around the order / invoice name generated by:

perch_shop_orders(); 

My diagnostics are:

Perch Runway: 3.0.8, PHP: 5.6.30, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.8), assets (3.0.8), categories (3.0.8), perch_blog (5.5.1), perch_shop_orders (1.2.2), perch_shop_products (1.2.2), perch_shop (1.2.2), perch_members (1.6.2)
App runtimes: <?php $apps_list = array( 'perch_members', 'perch_shop', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/stotto/public_html/dev/perch
PERCH_CORE: /home/stotto/public_html/dev/perch/core
PERCH_RESFILEPATH: /home/stotto/public_html/dev/perch/resources
Image manipulation: GD
PHP limits: Max upload 16M, Max POST 16M, Memory: 128M, Total max file upload: 16M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/stotto/public_html/dev
HTTP_HOST: dev.stotto.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Drew McLellan

Drew McLellan 2638 points
Perch Support

Does it happen on the current version? You're out of date.

Good point - will update and get back to you!

Okay, all updated but still the same error...:

Fatal error: Call to a member function to_array() on boolean in /home/stotto/public_html/dev/perch/addons/apps/perch_shop/lib/PerchShop_Order.class.php on line 538

My code on the page is still:

<?php perch_shop_order(perch_get('orderID')); ?>

Diagnostic now:

Perch Runway: 3.0.9, PHP: 5.6.30, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.9), assets (3.0.9), categories (3.0.9), perch_blog (5.5.1), perch_shop_orders (1.2.2), perch_shop_products (1.2.2), perch_shop (1.2.2), perch_members (1.6.2)
App runtimes: <?php $apps_list = array( 'perch_members', 'perch_shop', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/stotto/public_html/dev/perch
PERCH_CORE: /home/stotto/public_html/dev/perch/core
PERCH_RESFILEPATH: /home/stotto/public_html/dev/perch/resources
Image manipulation: GD
PHP limits: Max upload 16M, Max POST 16M, Memory: 128M, Total max file upload: 16M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/stotto/public_html/dev
HTTP_HOST: dev.stotto.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug, what does it output for the page?

Hi Drew,

I think it's somehow breaking the rendering of anything below it, and that is quite obvious by looking at the code rendered in the browser web inspector. For that reason I cannot output the debug unless I place it above:

<?php perch_shop_order(perch_get('orderID')); ?>

If I do place the debug code above it, I get:

Debug Message - Perch Runway 3.0.9
[60] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched route: orders/[i:orderID]
Using master page: /templates/pages/members/order.php
Page arguments:
Array
(
    [0] => /orders/39
    [orderID] => 39
    [1] => 39
)
[1] SELECT * FROM perch2_members_sessions WHERE sessionID='15844abcd55dcb48476d05c84ae109f559ddd1e8' AND sessionHttpFootprint='6bff0b11fa66a9de4ca447473522787687478fe2' AND sessionExpires>'2017-09-06 12:51:52' LIMIT 1
User is logged in
[1] SELECT * FROM perch2_pages WHERE pagePath='/orders' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1404
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1404
[nil] SELECT * FROM perch2_shop_sales WHERE saleFrom<='2017-09-06 12:51:00' AND saleTo>'2017-09-06 12:51:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
Using template: /templates/pages/attributes/seo.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you able to view Order 39 in the control panel?

Yes - definitely, just went into the perch admin and can see all details for it...

Does it help to see the debug showing up underneath in there? It's:

Debug Message - Perch Runway 3.0.9
[1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='5393b5e6bd774aafa6cad3cb2b1c673b' LIMIT 1
UPDATE perch2_users SET userHash='79ca4faadfc2110d9340fb208cc29c70' WHERE userID='1'
[43] SELECT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[11] SELECT itemValue FROM perch2_menu_items WHERE itemType='app'
[1] SELECT * FROM perch2_shop_orders WHERE orderID='39' AND orderDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID='47' LIMIT 1
[1] SELECT * FROM perch2_shop_customers WHERE customerID='5' AND customerDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_addresses WHERE addressID='87' AND addressDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_addresses WHERE addressID='88' AND addressDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_order_statuses WHERE statusKey='paid' AND statusDeleted IS NULL LIMIT 1
[1] SELECT oi.*, p.* FROM perch2_shop_order_items oi, perch2_shop_products p WHERE oi.itemType='product' AND oi.productID = p.productID AND orderID=39
[1] SELECT * FROM perch2_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[6] SELECT mi.*, p.privKey FROM perch2_menu_items mi LEFT JOIN perch2_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch2_menu_items WHERE itemType='app' AND itemValue='perch_shop_orders' LIMIT 1
[1] SELECT * FROM perch2_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch2_menu_items mi LEFT JOIN perch2_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
[9] SELECT * FROM perch2_shop_order_statuses WHERE 1=1 AND statusDeleted IS NULL ORDER BY statusIndex ASC
[9] SELECT statusKey FROM perch2_shop_order_statuses WHERE statusDeleted IS NULL ORDER BY statusIndex ASC
File: /addons/apps/perch_shop_orders/modes/order.detail.post.php
Adding: Invoice4
[0] SELECT promoID FROM perch2_shop_order_promotions WHERE orderID=39
[1] SELECT * FROM perch2_shop_countries WHERE countryID='0' LIMIT 1
No country set for address (name)
[1] SELECT * FROM perch2_shop_countries WHERE countryID='0' LIMIT 1
No country set for address (name)
Mode: order.detail
Queries: 22
Memory: 5.4486
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do all the products in the order still exist?

Thanks Drew,

You're right - the orders in there were for products that had been since removed.

I made a fresh order on a current product and that showed up no problem.

Out of curiosity, and to retain an order history for customers logging in, is it better to deactivate products than delete them?

Thanks for your help, Alex

Drew McLellan

Drew McLellan 2638 points
Perch Support

How did you delete the product?