HowTo Fix Interspire Shopping Cart “View Order Details” Error

URL

account.php?action=view_order&order_id=12345&x=a&y=b

Bug

The associated SQL query will pull down all the rows from the order_products table including those from other orders so if you have a lot of orders PHP will eventually run out of memory to pull the full query down so it can come out of left field.

Fix

Open:

/includes/classes/class.account.php

Find:

         $query = "
            SELECT
               
               o.*,
               op.*,
               oa.address_1,
               oa.address_2,
               oa.city,
               oa.zip,
               oa.country,
               oa.state,
               p.productid,
               p.prodpreorder,
               p.prodreleasedate,
               p.prodpreordermessage
            FROM
               [|PREFIX|]orders o
               LEFT JOIN [|PREFIX|]order_products op ON op.orderorderid
               LEFT JOIN [|PREFIX|]products p ON p.productid = op.ordprodid
               LEFT JOIN [|PREFIX|]order_addresses oa ON oa.`id` = op.order_address_id
            WHERE
               o.orderid = ". (int)$order['orderid'] ."
            ORDER BY
               op.order_address_id";

Replace with:

         $query = "
            SELECT
               
               o.*,
               op.*,
               oa.address_1,
               oa.address_2,
               oa.city,
               oa.zip,
               oa.country,
               oa.state,
               p.productid,
               p.prodpreorder,
               p.prodreleasedate,
               p.prodpreordermessage
            FROM
               [|PREFIX|]orders o
               LEFT JOIN [|PREFIX|]order_products op ON op.orderorderid
               LEFT JOIN [|PREFIX|]products p ON p.productid = op.ordprodid
               LEFT JOIN [|PREFIX|]order_addresses oa ON oa.`id` = op.order_address_id
            WHERE
               o.orderid = ". (int)$order['orderid'] ."
               AND op.orderorderid = ". (int)$order['orderid'] ."
            ORDER BY
               op.order_address_id";

Leave a Reply

Your email address will not be published. Required fields are marked *