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.

Custom code on checkout page of site not charging any shipping.

Hi there,

It's been so long since I last worked on a client site that uses FoxyCart 2.0 that I am at a bit of a loss to fix an error on his site where the shipping charge is not being added to his product orders.

Can someone please take a look at the underlying site checkout code and give me some input on where the problem might lie?

The shipping Javascript code that calculates the shipping is in the cart include template of the site.

The Javascript (or actually the template code used by FoxyCart) that actually activates the shipping calculation is at the bottom of the checkout template. It's mostly code that was given to me on this forum to implement the shipping charge on the checkout page back when I last worked on the site and is a bit difficult for me to follow in that it involves template code that I am still not all that familiar with.

Any help would be appreciated.

I am including the site URL in a whispered post.

Thanks.

Carlos

Comments
  • fc_adamfc_adam FoxyCart Team
    @carlos123,

    Hi! I believe the issue you're running into there is related to an old version of the flat rates snippet. I was able to replicate what you're seeing with your templates on my own test store, and updating to the latest version of the snippet got it working again.

    You can grab the latest version from here: https://wiki.foxycart.com/v/2.0/snippets/flat_rate_shipping_modification. You'd just pull out the custom logic from what you have and put it in the new snippet.
  • Thanks for the heads up Adam. Glad to hear you are still around!

    I am not sure if just pulling out the custom logic and inserting it into the new snippet will work Adam since some of the custom logic involves code you previously gave me to add to the bottom of the entire cart include template. Code which does NOT go into the section labeled /* BEGIN CUSTOM SHIPPING LOGIC */ and /* END CUSTOM SHIPPING LOGIC */

    That code is as follows...

    FC.client.on("cart-item-quantity-update.done", requireShipping);
    FC.client.on("cart-item-remove.done", requireShipping);
    FC.client.on("cart-coupon-add.done", requireShipping);
    FC.client.on("cart-coupon-remove.done", requireShipping);
    FC.client.on("customer-login.done", requireShipping);
    {% if cart_is_fullpage or context == 'checkout' %}
    FC.client.on("ready.done", requireShipping);
    {% else %}
    requireShipping();
    {% endif %}

    requireShipping() is the function just previous to that code and is not code I created.

    From what I remember the above code was intended to execute the requireShipping function when various events happened that might change the shipping charge. Such as when a product item is removed or when the product count is updated.

    So there is my truly custom shipping logic (which does indeed go into the section labeled with BEGIN and END) and then the code above which is at the very end of the store cart include template.

    Where would the code above (i.e. FC.client.on...etc.) go this time around?

    Is this code even needed anymore?

    Any additional advice you could give me on this would be appreciated Adam as I am a bit lost on what to do with the above FC.client.on code.

    I don't mean to bombard you with more questions Adam but I don't want to break things by moving code around and inserting it here or there without having a better understanding of how things work since the last time I made changes to the stores FoxyCart use.

    Thanks.

    Carlos
  • fc_adamfc_adam FoxyCart Team
    @carlos123,

    Good question. That code you highlighted is standard code for that version of the snippet from what I can tell. There wouldn't be any need to include that code in the new version.
  • Hi Adam,

    Still having trouble getting any shipping costs at all showing up. I copied the snippet of code for the new version as you suggested, inserted the custom code into the appropriate section in that code, and put it into the footer section within the store Configuration screen.

    Instead of 'TBD' I now get just a 0.00 for the shipping country as soon as the checkout page loads.

    Question...what is the relationship between the code inside the Cart include template and the footer code inserted into the Configuration area? Is it possible that the old code as found inside the Cart include template is interfering with the new code inside the Configuration area? Should I just remove the Cart include template code?

    Any further tips or input on this would be appreciated.

    Thanks.

    Carlos
  • Addendum...I deleted the Cart include template code and it didn't do any good (other than that the "TBD" shows up again but no change in shipping cost happens at all no matter what country is selected).

    Carlos
  • fc_adamfc_adam FoxyCart Team
    @carlos123,

    Looking at your store checkout - I am still seeing multiple versions of the snippet present - version 2.0.3 and version 2.0.9. Including two versions would definitely be conflicting - so you'd want to ensure that only one version is present.
  • Hi Adam,

    I am trying to fix this but I have a heck of a time understanding the relationship between the various pieces related to FoxyCart within the Admin interface so as to have some idea of what to fix where.

    The snippet you refer to is meant to be inserted into the Configuration area of the Admin interface under Templates. I understand that.

    But there is also a Cart Template and a Checkout Template both of which previously worked.

    If the new version of the snippet is inserted into the Configuration options am I to understand that I should completely get rid of any custom Cart Template or Checkout Template? I got rid of the Cart Template entirely and that change did not do anything to fix this.

    How do you know that there are multiple versions of the snippet present? Can you give me some hint as to where these multiple versions might reside so that I can eliminate one of them? I completely eliminated the Cart Include template and the Checkout template has no such snippet in it's code as far as I can see so I don't understand where you are seeing multiple versions of the same snippet.

    Perhaps you are looking at the default store that shows up when entering the Admin interface which is for a different site that the one I am having trouble with. Don't know. There are two stores under the same login Admin interface.

    One other thing I don't understand. I can insert custom code in between the BEGIN CUSTOM SHIPPING LOGIC / END CUSTOM SHIPPING LOGIC constraints but how exactly is that code going to be called and executed when a change happens? I mean it's got to be called somehow right?

    All I see is a section of code at the end that says...

    {% if cart_is_fullpage or context == 'checkout' %}
    FC.client.on("ready.done", requireShipping);
    {% else %}
    requireShipping();
    {% endif %}

    I assume that means that when the page loads that the function requireShipping is called but when I look at that function it makes no calls to my custom code inserted into the aforementioned BEGIN.../ END... constraints. So how is my custom code supposed to be called and executed?

    This is all very confusing. It's not the Javascript that is so very confusing since Javascript is Javascript. Rather it is the way FoxyCart pulls pieces from this or that place and uses a template language separate from Javascript to pull this or that value from the Admin in various places and do various things based on various other values that come from places that I am not yet clear about.

    Any additional input you could give me so as to make heads or tails of this and get past this problem would be appreciated.

    If you need URL's or any other info whispered please let me know.

    Thanks.

    Carlos
  • fc_adamfc_adam FoxyCart Team
    @carlos123,

    Sure thing. I'm loading the website you whispered to me earlier, and viewing the source. When doing that I'm seeing two copies of the snippet. As you noted you're not using a custom cart include template anymore - so it shouldn't be. I resaved that and it's now dropped the additional snippet - so it's now gone. Not sure what caused it to stick around.

    With the older script gone - I'm seeing it still not work, and I believe it's an issue with the latest version of the snippet. I tried it with the previous version and it worked there - so I've rolled the snippet page back to that version as well. If you grab the version shown on the page now (2.0.8) and use that, it should start working for you. It does on my test store at least. Sorry for the confusion there.

    As for the javascript - the logic that makes it run is contained within the minified code. It hooks into the necessary events to run as it's needed.
  • Thanks Adam. It's working now.

    Carlos
Sign In or Register to comment.