lat9 / upsxml

UPS-XML for Zen Cart
3 stars 4 forks source link

order delivery being empty array #26

Closed proseLA closed 3 years ago

proseLA commented 3 years ago

in a v157 site, an admin can place an order for a customer. in such a situation, it is entirely possible (and seen in the wild) that the $_SESSION['sendto'] would be set to 0 here:

https://github.com/zencart/zencart/blob/0bf8a8f076843612e87e25966f9f855f901dc2cd/includes/classes/order.php#L308

if zero, $order->delivery will be an empty array.

which then results in undefined notices here:

https://github.com/lat9/upsxml/blob/5a0dfad3f46039a222045bb73f8a2b52d83f0889/includes/modules/shipping/upsxml.php#L333

and here:

https://github.com/lat9/upsxml/blob/5a0dfad3f46039a222045bb73f8a2b52d83f0889/includes/modules/shipping/upsxml.php#L353

lat9 commented 3 years ago

In my mind, the real question is why $_SESSION['sendto'] isn't set for that admin-placing-order scenario.

proseLA commented 3 years ago

i suppose the question is whether this query returns any records:

SELECT c.customers_id, customers_default_shipping_id, address_book_id
FROM customers c
left join address_book  ab on c.customers_id = ab.customers_id
and customers_default_address_id = address_book_id
where isnull(address_book_id);

but i seem to have seen it far more times than my results for this query would indicate.

even after looking at this query and logging some data, then i'm still not seeing how the delivery array is empty.

proseLA commented 3 years ago

In my mind, the real question is why $_SESSION['sendto'] isn't set for that admin-placing-order scenario.

fyi, i am still looking into this situation... i think i have resolution in 1 place, but not in another.... i have created some logging that will hopefully provide me the "golden nuggets" for resolution.

proseLA commented 3 years ago

ok, thanks for pointing me in the right direction! i think i have this under control and will close it now. appreciate the help!