The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

2.0 Custom Flat rate snippet

PhilippePhilippe Member
I am trying to implement this, and have been successful except in using a reset when changing countries in the side cart.

Specifically, we have a product code AU-OPT-RACE-CC that can not ship to NZ. When that product is in the cart we need to take out all shipping methods.

This comes a the end of our custom code and we have used :

FC.customFlatRates.remove('all');
FC.customFlatRates.error('Sorry, we cannot ship Opti race sails to NZ');

The error message displays fine, but the shipping methods are not removed if the customer toggles between Australia and New zealand.
(note, we also have a FC.customFlatRates.reset(); before we astray adding shipping methods)

To reproduce:

-1- use test page
http://www.i-sails.us/test.html

-2- add firt product (optimist race sail)
Ship to Australia, zip code 3000 - a proper meths shows, all is good.

-3- change your mind and ship to your summer house in New Zealand, post code 3591
Note that the "no shipping to NZ message displays", but you still have a free shipping method left...

-4- Even weirder, if you change to the australia 3000 zip code, then back to the summer house in NZ 3591, you now have a Australia shipping method left- and the no shipping to NZ message, coming from FC.customFlatRates.error('Sorry, we cannot ship Opti race sails to NZ') shows. That instruction is a the bottom of the code, one line after the FC.customFlatRates.remove('all'); that does not seem to work....


Our test store is i-sailsteststore.foxycart.com
Comments
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    Is this still happening for you? I just followed your steps but it's correctly displaying shipping and/or errors as expected
  • Yes it does. I thought there might be some weird cookie issue, and I tried with a fresh computer, and the problem was there too. I have tried with Safari and Firefox too. See screenshot here, the shipping method survived at the bottom, even though the "no ship to NZ " message is present :
    http://www.ispinnakers.com/i-sails/test/AUNZ.jpg

    Sorry for the delay in my follow up, somewhat the email containing your reply got lost....
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    Ah thanks for the screenshot - I see what you mean now. It's sticking around in the totals section, rather than within the shipping section. I can see that as well.

    I'll take a look and see if I can get that fixed up in the snippet.
  • Let me know when you got it. 1 thing that would be cool with the snippets is to date them in the comments. This way one can compare one's version with the current version on the foxy cart site, and determine if one has the latest or not....
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    There is a version number right above the block of the snippet code to tell if you're on the latest version or not. For example, your snippet in your store is the following:

    /* Flat Rate Shipping Modification Logic v2.0.6 */

    I'll follow up related to the issue hopefully soon.
  • Hi Adam, any joy on this one please?
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    I'm sorry for the extended delay from my side. This has lead to an issue we'll need to fix in our javascript, and we have an active ticket to look into that as soon as we can. I've noted this thread on that ticket as well, so we'll update you as soon as we have made any changes with that.
  • OK. Thanks for the update.
  • PhilippePhilippe Member
    edited June 2015
    Adam,

    It seems that my code that was working before, with the exception of the small problem at the root of this post, has stopped working - and I did not change it. Specifically, some JS variable calculation does not seem to work any longer.

    It is very difficult to debug as I use code added in the configuration field, and I can not seem to figure out how to debug / watch the variable states using the firebox/firebug combination. Is there a not anywhere on how to set up a debug environment for code added into the configuration footer?
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    With how the custom snippets work, they're unfortunately not really an easy thing to debug as such. Could you let me know a postcode that I could test on your store that isn't working - and what it should be, and I'll be happy to take a look.
  • I sorted my actual issue away, but I am setting up another store, and might have further questions ....
  • fc_joshfc_josh FoxyCart Team
    Hi Philippe.
    Just wanted to let you know that we pushed out a fix for this issue today. Let us know if we can assist with anything else.

    Thanks,
    Josh
  • I have an issue that seems related to the original one - if not the same one.

    Here is how to test:
    - Got yo our test page here:
    http://www.i-sails.fr/test.html
    Order a a package laser standard sail by clicking the button immediately below the cart button in the body.

    the side cart comes up

    If you set the country to France and the zip code to 31500, shipping calculates correctly to 19 Euros.

    If you now remove that item, the shipping should disappear as the cart is now empty - however a shipping method remains, possibly because a variable that my js code resets to false when rating the script has not been reset - i.e. possibly the code has not been read again upon emptying the cart.... if you refresh the page however, everything works has designed....

    The variable that does not seem to reset is started as var hasEU_DIN = false;
    it should be changed to true and cause a shipping method to appear when a product with category EU-DIN is loaded, through this loop:

    for (p in FC.json.items) {
    switch (FC.json.items[p].category) {
    case "EU-DIN":
    hasEU_DIN = true;
    countEU_DIN = countEU_DIN + FC.json.items[p].quantity;
    break;
    }
    }

    It should therefore reset to false - and stay there when the code is rerun upon emptying the cart - but it does not....
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    I just tested your checkout - and after adding the test product and then removing it - the shipping doesn't persist with the empty cart. Are you still seeing this issue?
  • PhilippePhilippe Member
    edited July 2015
    Nope - was just testing it and find it works now. I assume this is a function of my early js code being far from perfect, and creating the problem. Spent quite a bit of time, fixed it and it must have taken a while for the change to propagate somewhat though the various caches between your servers and locally on my machine....mot likely the latter...
Sign In or Register to comment.