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.

Foxycart 2.0 Upgrade issues with

NetNutNetNut Member
We are in the process of updating our main site to Foxycart 2.0 and have run into an issue where the side cart will not function and instead it takes you to the full page cart.

Here is a breakdown of the error's and testing we went through up until this point.

The live test site for this issue is Here
This is the only page with an updated add to cart button and it is only on the first product: green mosquito netting.

The current console errors looks like this:

Here is the code where the error begins:

Here is the code where the "undefined" function is defined.

Oddly enough when we remove our all of our scripts included using require.js and use the loader.js script from the sample code page the side cart works. This leads us to believe that there is some sort of conflict with the method our require.js uses and the methods loader.js uses to bring in dependancies.

Could you guys take a peek at this and offer any assistance?
  • brettbrett FoxyCart Team
    @NetNut, I'm thinking maybe that test page is still being modified, but could you clarify how you're including the loader.js? I don't see it on that page. (I saw the js error on the first load, but don't see it now, so maybe you're working on it right now?)

    I do see an error on the full page cart, however. But I'm thinking that's not where we're wanting to focus right now?
  • @brett,
    You won't see it in the view source but it gets loaded asynchronously with require.js. The require script tag can be seen on line 21 in the source: <script data-main="" src=""></script>

    If you inspect the page and open up the elements the foxycart loader.js script tag gets placed one tag up from the closing head element: <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="foxy" src="//"></script> .

    We have noticed that sometimes the error isn't thrown, but if you refresh it comes back up. Also, yes we noticed the error on the full page cart, but we are hoping it is caused by the same issue.
  • fc_adamfc_adam FoxyCart Team

    I'm really sorry about the delay in responding to you here. You mentioned that Sidecart works if you include loader.js as it is noted on our Sample Code page in the admin and remove your own scripts. Does the error occur if you include loader.js as noted on our side, and also still maintain your own includes with require.js?
  • NetNutNetNut Member
    edited March 2015
    No problem. It still does the same error when we tried what you described above. We are in the process of revamping our require.js modules and we think this should solve the issue. I will post back with the results once they are done, which should be around Monday or Tuesday.
  • brettbrett FoxyCart Team
    Thanks @NetNut. The delay in responding is my fault. I've had the tab open, but digging into this particular issue is the sort of thing that tends to require far more brainpower than I have available by the time I get to support in my day. Glad to hear you have an idea. Let us know how it goes.
  • So even after rewriting our require.js modules the issue boils down to the error with the function extendTwig in the loader.js and this happens whether we load it in with require or simply on the page with the script from the sample code page.

    Same thing happens as before, if we remove all of our javascript it works fine. As a test we tried removing everything else from our require.js modules except for jquery and loader.js from // . This still gives the twig error. After removing jquery this still throws the same error loading only foxycart through require.

    -Foxycart and our other modules in require: Twig.extendFilter("money_format", function(value) {
    -Foxycart on page and our other modules in require: same error.
    -Only foxycart and jquery(v 1.11.1 as reccomeded) in require: same error.
    -Only foxycart in require: same error.
    - Only foxcart on page: everything works. Everything except anything other than foxycart, haha.

    It seems that the loader.js script is simply incompatible with using require.js on a site anyway you cut it, which is pretty weird.
  • brettbrett FoxyCart Team
    Hmmm… I have no idea. It doesn't look like anything covered here either, right?
    I think we'll need to get our amazing js expert to take a look at this. Give us a few.
  • evgevg FoxyCart Team
    Hi @NetNut,

    When you use RequireJS, Twig.js thinks it's a module and works a bit differently. But our library couldn't detect it.
    The patch is already done and will be pushed live soon.
    Thank you for the catch!

    I think, one day FC code will be refactored as an AMD module and will be supported by RequireJS out of the box, without a need to use the "shim" object.
  • Great, thanks for looking into that @evg and @brett ! We will test this and get back to you once we try it out.
  • lukeluke FoxyCart Team
    Hey @NetNut. We just pushed out an update which should resolve this issue with twig.js and require.js. Please let us know if you're still seeing any problems.
  • Everything went great in the testing after that fix. It's up and live now. Thanks for the help!
Sign In or Register to comment.