lat9 / upsoauth

A Zen Cart UPS shipping module that makes use of UPS' RESTful/Oauth API
GNU General Public License v2.0
3 stars 3 forks source link

correct quote method #37

Closed proseLA closed 20 hours ago

proseLA commented 1 week ago

per the docs, id and methods are required. in addition, without the id opc will generate errors here.

without methods, previous versions of bootstrap will generate errors on the shipping estimator. it seems that the current version of bootstrap does all of these conditional checks to ensure that methods are there. sending an empty array would prevent the need to do all of those jumping through hoops there.

similarly, the quote method should return an array not a boolean.

if no methods are available, and you do not want to display an error message to the user, an empty array is what should be expected of this method. this PR replaces those returns of false to an empty array.

finally, while i am here, i see no need for all of the lines from 384 to 428. what is wrong with the message provided by ups? it just makes it easier to display their error message than to hard code one's own. i think all of that code can be replaced by:

            $error_message = sprintf(MODULE_SHIPPING_UPSOAUTH_ERROR, $ups_error_code);
            if (!empty($all_ups_quotes->response->errors[0]->message)) {
                $error_message = $all_ups_quotes->response->errors[0]->message;
            }

but alas, i doubt you will want to merge that.

proseLA commented 1 week ago

oh, and if you want to test just use an armed forces address. ie, something like:

PSC 817 BOX 2435 Fpo AE 09622-0025 United States