Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Phil Gilligan 25 posts 136 karma points
    Aug 13, 2013 @ 12:52
    Phil Gilligan
    0

    renderTemplateFile returning null

    Hi,

    I'm using the Javascript API for Tea Commerce 2.1.3 on an Umbraco 6.2.1 build.  

    I am calling the renderTemplateFile method in the following way:

    var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1 });

    Using the Google Chrome developer tools, I can see the '/base/TC/FormPost.aspx' request being posted to the server and can also see the expected HTML response being returned from the 'MiniBasketPopup.cshtml' view.  However, the variable 'cartContent' is returning null.

    Please could anyone suggest what I may be doing wrong?

    Kind Regards

    Phil

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 13, 2013 @ 13:02
    Rune Grønkjær
    1

    What cartContent variable? You might need to be more specific?

    Have you enabled the razor file in the Tea Commerce settings for the store?

    /Rune

  • Phil Gilligan 25 posts 136 karma points
    Aug 13, 2013 @ 13:08
    Phil Gilligan
    0

    Hi Rune,

    Thanks for the quick response!

    I'm declaring a variable cartContent to take the output of the TC.renderTemplateFile method call.  It is shown in the first part of this line:

    var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1 });

    I've enabled the razor file in the store and I'm seeing the expected view being returned in the XHR response.  The POST request also gets a status code of 200 OK so I know that the request and response are fine.  It's just the 'var cartContent =' bit that doesn't seem to be working.

    Any ideas?

    Phil

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 13, 2013 @ 14:03
    Rune Grønkjær
    0

    Hmm. Actually sounds like it's running the call async and thereby returns nothing, but that's not supposed to happen. Do you have a link where I can try it? If it's a secret link you can mail it to me here: rg [at] teasolutions.dk

    /Rune

  • Phil Gilligan 25 posts 136 karma points
    Aug 13, 2013 @ 14:37
    Phil Gilligan
    0

    Thanks Rune.  I've sent a link to the email address you provided.  Hope all makes sense.  Please let me know if you need any further information.

  • Anders Burla 2560 posts 8256 karma points
    Aug 13, 2013 @ 18:50
    Anders Burla
    0

    Hi Phil and Rune

    Looking at the source code of the Tea Commerce JavaScript API it looks like th renderTemplateFile indeed is called async. I will have Rune look into fixing this :)

    Kind regards
    Anders

  • Phil Gilligan 25 posts 136 karma points
    Aug 13, 2013 @ 18:56
    Phil Gilligan
    0

    Thanks Anders.  I have a pressing need to use this feature in the next few days.  Will you be able to supply an updated ecommerce.js script within that timescale or should I start looking for an alternative way update my cart?

  • Anders Burla 2560 posts 8256 karma points
    Aug 13, 2013 @ 19:20
    Anders Burla
    0

    Try send async: false in the settings object

    Kind regards
    Anders

  • Phil Gilligan 25 posts 136 karma points
    Aug 13, 2013 @ 20:04
    Phil Gilligan
    0

    I added 'async: false' to line 254 of jquery.form.js but still getting a null.  Im not sure if this was the correct location to make the change so I'm happy to wait for Rune to work though the fix.

  • Anders Burla 2560 posts 8256 karma points
    Aug 14, 2013 @ 07:36
    Anders Burla
    101

    It should be in this line of code you posted :)
    var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1, async: false });

    Kind regards
    Anders

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 14, 2013 @ 08:14
    Rune Grønkjær
    0

    Thanks for the link Phil. What Anders writes works like a charm on your site. It was in Tea Commerce v1 that you didn't have to add the async=false setting yourself.

    The reason is that you now have the option of making the call async and then hook into the successfn and handle the response there. Adding the async:false setting will make the method return the server response directly.

    I will change the documentation of the method, and add the "new" settings options!

    /Rune

  • Phil Gilligan 25 posts 136 karma points
    Aug 14, 2013 @ 09:43
    Phil Gilligan
    1

    Thanks guys!  I've tested it and it looks great. I'll come back and give you both high fives when I've got enough karma.

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 14, 2013 @ 09:46
    Rune Grønkjær
    1

    Cool. Here's a high five from me to you then :)

    Thanks for pointing out this documentation problem!

    /Rune

  • suzyb 474 posts 932 karma points
    Aug 30, 2013 @ 15:07
    suzyb
    0

    Could you add a bit about having to enable the templates for rendering from javascript in the renderTemplateFile documentation.

    I've spend half an hour trying to work out what I'd missed that was causing an exception till I gave this thread a read and Rune's first response pointed me in the right direction :(

  • Anders Burla 2560 posts 8256 karma points
    Sep 02, 2013 @ 10:38
    Anders Burla
    1

    Is this "Remember" statement good enough?
    http://documentation.teacommerce.net/javascript-api/template-files/rendertemplatefile/

    Kind regards
    Anders

  • suzyb 474 posts 932 karma points
    Sep 02, 2013 @ 11:45
    suzyb
    0

    Perfect xD

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft