Custom End Point Shipping: error message shows in fc log, but does not appear in side cart

Hi,

We are finalizing the shipping Custom End Point deployment and we have one small last issue - in some cases we need to display an error message - in those case we can see the error message in hte admin interface (reports--> error log) but the message itself does not display in the side cart.

to reproduce:
test page : http://testml.isails.com/laser-store/

Click on australian store flag to display Austrlian products.
Pick hte first product (standard sail)
Enter a non AU or NZ shipping address - no rates and no error message display

Our custom logic includes:

if ($customer_country != "NZ" && $customer_country != "AU") {
$rates->reset();
$rates->error("We normally do not ship dinghy sails from the Australia store outside AU and NZ. Please contact us for a custom shipping quote");
}


This does not display any rates, but also faisl to display the message - although the error log contains:
Error Message: Custom Shipping Error: We normally do not ship dinghy sails from the Australia store outside AU and NZ. Please contact us for a custom shipping quote
GET Values: callback=jQuer yetc
Our full custom end point is at isails.biz/isails/testml/wp-content/themes/twentythirteen-child/pa/CustomEndPoint.php
Comments
  • brettbrett FoxyCart Team
    Hi @Philippe. We actually were just discussing this internally yesterday. We'll get back to you soon.
  • lukeluke FoxyCart Team
    Hello @Philippe. Based on our logs, it looks like your response json is properly formatted with error details, so it seems like it should be showing up.

    However, when I tried to test I was seeing rates returned:

    image

    The way our system works is even if one service provider returns an error due to the weight of the package or some other constraint, if the other providers can still return a value, then no error is shown to the customer though one will still be logged in your store admin for your benefit.

    Can you give me the specific address you were using to test with where you saw no returned results and no errors?

    Thank you.
  • You can take any US address - for example zip code 84060 - however you need to load an Australian product, as explained in original question, and shown by the product code starting with AU - see example here: tinypic.com/r/f53jhs/9
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    Thanks for clarifying - sorry for missing that.

    I can replicate what you're seeing - where for an AU product with a US shipping address, there isn't any rates or errors shown. Checking the actual request in the browser console though - there are technically rates being returned - but they're being hidden with the live rate modification snippet. As an example, I see the following rates returned: Customer Pickup, USPS Priority Mail 2-Day, FedEx 2 Day.

    As we're getting rates returned still - we don't pass on any error messages to the cart/checkout.

    For your set up - the best bet will be to handle the error message in your custom logic. You could do that like this:
    if (FC.json.locale_code == 'en_AU') {
    FC.customLiveShipping.hide('FedEx ');
    FC.customLiveShipping.hide('USPS ');
    FC.customLiveShipping.hide('Customer Pickup');

    var has_rates = false;
    for (var r = 0; r < FC.json.shipping_address.shipping_results.length; r++) {
    if (!FC.json.shipping_address.shipping_results[r].hasOwnProperty("hide") || FC.json.shipping_address.shipping_results[r].hide == false) {
    has_rates = true;
    }
    }
    if (!has_rates) {
    FC.util.addError("shipping-results", "We normally do not ship dinghy sails from the Australia store outside AU and NZ. Please contact us for a custom shipping quote");
    }
    }
    That basically just loops through the rates and checks if they're all hidden (so none will end up being shown to the customer), and returns an error accordingly.
Sign In or Register to comment.