Forum

Thread tagged as: Question, Shop

Problem with perch_shop_order_successful

If I use this code on my checkout:

          perch_shop_checkout('manual', [
            'status' => 'manual_order',
            'return_url' => $return_url,
            'cancel_url' => $cancel_url,
          ]);       

The order will be added to the system with a status of Manual_order. However, on the return_url page, when I check for

    if (perch_shop_order_successful()) { ...

It does not pass and goes to the unsuccessful else statement. (manual_order is an active status with a number of 101)

When I remove the 'status' => 'manual_order' line, and get to the return_url, order _successful is checking correctly.

Am I doing something wrong? Does the order_successful function expect to find something that my status of manual_order is messing up?

Thanks, Monty

Monty Lewis

Monty Lewis 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you checked the debug?

This is the debug on the the $return_url page:

I don't see anything out of the ordinary:

Debug Message - Perch Runway 3.0.8
[33] 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 page: /cart/manual-confirm, so not using routes.
Using master page: /templates/pages/purchases/payment/confirm-manual.php
[1] SELECT * FROM perch2_members_sessions WHERE sessionID='28bb949c3e0e7c743e5e631a7466b9668afbf03a' AND sessionHttpFootprint='903672353e70b1a5d00aedfb8cde7912ab583358' AND sessionExpires>'2017-07-04 07:14:22' LIMIT 1
User is logged in
[1] SELECT * FROM perch2_pages WHERE pagePath='/cart/manual-confirm' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=52002
[1] SELECT * FROM perch2_shop_cart WHERE cartID=52002
[nil] SELECT * FROM perch2_shop_sales WHERE saleFrom<='2017-07-04 11:14:00' AND saleTo>'2017-07-04 11:14:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
[12] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/cart/manual-confirm' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-010-008', '000-010', '000') ORDER BY pageTreePosition DESC
Using template: /templates/navigation/navigation-main.html
[5] Using template: /templates/navigation/navigation-main-2.html
Using cart from cache.
[1] SELECT * FROM perch2_shop_products WHERE productID=106 AND productDeleted IS NULL LIMIT 1
[4] SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products WHERE parentID=106 AND productDeleted IS NULL ORDER BY productOrder ASC
[1] SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po WHERE o.optionID=po.optionID AND po.productID=106 AND o.optionDeleted IS NULL ORDER BY optionPrecendence ASC
[4] SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode FROM perch2_shop_option_values WHERE optionID=9 AND valueDeleted IS NULL ORDER BY valueOrder ASC
[4] SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.* FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov WHERE pov.productID='106' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL AND o.optionID='9' ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC
[43] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] Using template: /templates/shop/cart/mini.html
Missing variant.
Using template: /templates/pages/attributes/description.html
[1] SELECT * FROM perch2_shop_orders WHERE orderID=108 AND orderDeleted IS NULL LIMIT 1
Is paid?
[3] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/cart/manual-confirm' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Sponsors' AND (regionPage='/cart/manual-confirm' OR regionPage='*')
[6] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=18 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
[6] Using template: /templates/content/sponsors/_footer_logos.html
Using template: /templates/mailchimp/subscribe_email_address.html
[5] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/cart/manual-confirm' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-010-008', '000-010', '000') ORDER BY pageTreePosition DESC
[5] Using template: /templates/navigation/navigation-footer.html
Using cart from cache.
[1] SELECT * FROM perch2_shop_products WHERE productID=106 AND productDeleted IS NULL LIMIT 1
[4] SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products WHERE parentID=106 AND productDeleted IS NULL ORDER BY productOrder ASC
[1] SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po WHERE o.optionID=po.optionID AND po.productID=106 AND o.optionDeleted IS NULL ORDER BY optionPrecendence ASC
[4] SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode FROM perch2_shop_option_values WHERE optionID=9 AND valueDeleted IS NULL ORDER BY valueOrder ASC
[4] SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.* FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov WHERE pov.productID='106' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL AND o.optionID='9' ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC
Using template: /templates/shop/cart/your_cart.html
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Globals' AND (regionPage='/cart/manual-confirm' OR regionPage='*')
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=21 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
[1] Using template: /templates/content/globals/_phone_number.html
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=21 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
[1] Using template: /templates/content/globals/_email_address_main.html
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=21 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
[1] Using template: /templates/content/globals/_social_footer.html
Request time: 0.1793
Process time: 0.1789
Memory: 4.4649
Drew McLellan

Drew McLellan 2638 points
Perch Support

What is the order status of 108 ?

Manual_order

oh. So perch_shop_order_successful() specifically looks for Paid?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, it looks for a status of paid.

If you're doing a manual order, you know the status, so why do you need to check it?

Right. Got it