Copied to clipboard

Flag this post as spam?

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


  • Moran 285 posts 934 karma points
    May 06, 2013 @ 07:56
    Moran
    0

    product variant change in product/view.cshtml

    I have a product with 2 variants, but when I change the product's variant in the ddl I can't see the product chnaging. 

    does this line of code does the refreshing page part? what do I need to check in order to make sure that I haven't droped anything important while applying my store template on the current store.

    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">

    Thanks for the help 

  • Rune Grønkjær 1372 posts 3103 karma points
    May 06, 2013 @ 08:12
    Rune Grønkjær
    100

    Hi Moran,

    Because of the ajaxForm class on the form, the Tea Commerce JavaScript API will kick in, and post the form for you. That means that if you want to update the UI, you must do so in the JavaScript events. In the Tea Commerce starter kit a bunch of events are used to update the minicart and cart. Take a look at the ecommerce.js file, which contains the event stuff.

    /Rune

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 08:17
    Moran
    0

    Thank you for the fast reply. I will take a look and update this thread.

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 08:55
    Moran
    0

    Thank a lot now it's working :), but I have another issue. 

    If I change the product to it's second variant I can see the change, but if I try to change the product back to it's first variant I can't see the change. this also happens in the starter-kit store

  • Rune Grønkjær 1372 posts 3103 karma points
    May 06, 2013 @ 09:38
    Rune Grønkjær
    0

    Hi Moran,

    That's great. Please mark the correct answer, so others can see it.

    About your second issue, I'm having a hard time understanding the problem from your description. Is it when the variant is changed in the select dropdown? Is it in a specific browser? It works fine in my firefox and chrome.

    /Rune

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 09:51
    Moran
    0

    I have uploaded a short video of this issue, in this case it's IE 10 but the issue is also present on chrome.

  • Rune Grønkjær 1372 posts 3103 karma points
    May 06, 2013 @ 10:28
    Rune Grønkjær
    0

    Hi Moran,

    I still cannot replicate the error. Could you please check the browser javascript console to see if any important errors a thrown?

    Here's a video of my test in IE 10. Same result in Chrome and Firefox here:
    http://www.screencast.com/users/runegronkjaer/folders/Jing/media/13007eab-3115-44f4-b9d1-062521b38c50

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 10:59
    Moran
    0

    This is odd I can't see any errors and this is the XHR log, after the first time I don't see any XHR calls.

    1. XHR finished loading: "http://localhost:50533/base/TC/FormPost.aspx". jquery.min.js:4
      1. f.extend.ajaxjquery.min.js:4
      2. TCService.postToServertea-commerce.min.js:645
      3. TC.renderTemplateFiletea-commerce.min.js:600
      4. (anonymous function)ecommerce.js:70
      5. f.event.dispatchjquery.min.js:3
      6. h.handle.ijquery.min.js:3

  • Rune Grønkjær 1372 posts 3103 karma points
    May 06, 2013 @ 11:05
    Rune Grønkjær
    0

    So no servercalls are made with ajax when the problem starts occurring? Can you repplicate that on other computers as well? Firebug or the Chrome console will show you whatever server calls are made (Don't know what the XHR thing is, sorry :))

    /Rune

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 11:16
    Moran
    0

    Ok, let me check

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 11:44
    Moran
    0

    I can't see any server calls after the first call and no errors too. in the first time I can see this event firing but on the second time nothing.

    jQuery.ajax({
    type:'POST',
    url:'/base/TC/FormPost.aspx',
    data:formData,
    async:async,
    success:function(json,success,response){rtnData=TCService.success(json,success,response,null,settings);},
    error:function(json){TCService.error(json,settings);},
    cache:false,
    contentType:'application/x-www-form-urlencoded; charset=utf-8',
    dataType:dataType
    });
    returnrtnData;
    };
  • Rune Grønkjær 1372 posts 3103 karma points
    May 06, 2013 @ 11:57
    Rune Grønkjær
    0

    Can you replicate on other computers? Maybe a security issue in your end?

    It even works on my IPhone. So it's hard to debug :)

    /Rune

  • Moran 285 posts 934 karma points
    May 06, 2013 @ 12:54
    Moran
    0

    Sure, but I don't think I be able to do it today, if it's okay with you I will check it on my partner computer tommorow and update this thread. thanks :)

  • Moran 285 posts 934 karma points
    May 07, 2013 @ 10:41
    Moran
    0

    Hi it's me again:

    I have stumble upon this error, not sure if it's related but I am getting it in the sample store.

    1. Uncaught TypeError: Cannot read property 'orderLines' of undefined ecommerce.js:331
      1. getOrderTotalQuantityecommerce.js:331
      2. updateMiniCartecommerce.js:87
      3. (anonymous function)ecommerce.js:14
      4. (anonymous function)

    anyway can you tell ,where can I start debug this issue? I saw this function in the  RENDER TEMPLATE EVENTS

    jQuery(function(){
    jQuery('.product').on('change','select.productIdentifier',function(){
    varvariantSelect=jQuery(this),
    productIdentifier=variantSelect.val(),
    product=variantSelect.closest('.innerProduct'),
    refreshwithtemplate=product.attr('refreshwithtemplate');
    TC.renderTemplateFile({
    templateFile:refreshwithtemplate,
    pageId:productIdentifier,
    successfn:function(html){
    product.after(html).remove();
    }
    });
    });
    });
  • Rune Grønkjær 1372 posts 3103 karma points
    May 07, 2013 @ 11:01
    Rune Grønkjær
    0

    Sounds like "order" is undefined in some case.

    Do you have a link where I can check it out. You can e-mail it to me at rg [at] teasolutions.dk

    /Rune

  • Moran 285 posts 934 karma points
    May 07, 2013 @ 11:07
    Moran
    0

    unfortunately not at the moment. I need to upload the site to my server and that is going to take some time... I will email you the link as soon as I finish upload it to my server.

    Can this problem be related to this issue? what about the function I mentioned in my previous reply?

  • Rune Grønkjær 1372 posts 3103 karma points
    May 07, 2013 @ 11:24
    Rune Grønkjær
    0

    Yes, it could be related. Any JavaScript error will stop the entire JavaScript thread.

    Again you can use firebug to debug it and see what exactly happens, if you cannot wait for me. You can insert breakpoints in the script and read the value of the different objects. That's what I will do when you can send me a link.

    /Rune

  • Moran 285 posts 934 karma points
    May 07, 2013 @ 13:11
    Moran
    0

    I think the issue is in this function:

    TC.bind('afterCartUpdated',function(data,jQForm){
    //Set elements in updating mode
    resetUpdatingElements(jQForm,function(){
    updateMiniCart(data.order);
    updateCart(data.order,true);
    });

    the variable data is defined but the property data.order is undefiend this is the content of data:

    <div id="product" refreshwithtemplate="product\view.cshtml" class="product innerProduct hasVariants" nodeId="1265" itemscope="" itemtype="http://schema.org/Product"> <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm"> <input name="storeId" type="hidden" value="1" /> <input name="AddOrUpdateOrderLine" type="hidden" value="productIdentifier : productIdentifier, orderLineId : orderLineId, quantity : quantity, propertyKeys : propertyKeys" /> <h1> Corvina Cabernet </h1> <div class="productWrap"> <div class="productImage"> <img src="/ImageGen.ashx?Width=378&amp;Height=378&amp;Constrain=True&amp;Image=/media/4953/Red Wine.jpg" class="productImage" alt="Corvina Cabernet" title="Corvina Cabernet" /> </div> <div class="productContent"> <div class="description"> <p>A really cheap and inexpensive red whine in a two liter pack</p> </div> <div class="productPrice" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer"> <span itemprop="price"> $37.40 </span></div> <div class="variants"> <select name="productIdentifier" class="productIdentifier"> <!-- loop through each of the variant products --> <!-- do whatever you like here --> <option value="1264" > 1l </option> <!-- do whatever you like here --> <option value="1265" selected="true"> 2l </option> <!-- do whatever you like here --> <option value="1266" > 5l </option> </select> </div> <div class="actions"> <input type="submit" value="Add to cart" class="addToCart btn btn-brown btn-cart" /> <span class="addingToCart btn btn-addingtocart btn-brown">Adding to cart</span> </div> <div class="quantity noPrint"> <input type="text" name="quantity" class="quantity" value="1" /> </div> </div> </div> </form> </div>

    is it supposed to be that?

  • Rune Grønkjær 1372 posts 3103 karma points
    May 07, 2013 @ 13:15
    Rune Grønkjær
    0

    In some cases yes. Try adding this if statement like this:

    TC.bind('afterCartUpdated',function(data,jQForm){
    //Set elements in updating mode
    resetUpdatingElements(jQForm,function(){
    if(data.order){
    updateMiniCart(data.order);
    updateCart(data.order,true);
    }
    });
  • Moran 285 posts 934 karma points
    May 07, 2013 @ 13:39
    Moran
    0

    Thanks

    I tried that but for some reason in debug mode I can't see that in the second time it's hitting my breakpoints, it's like it does nothing after the first time I change the product variant.

    I tried putting breakpoints in the two main methods:

    setUpdatingElements

    and

    resetUpdatingElements

    but it doesn't seem to get to those methods in the second time.

  • Rune Grønkjær 1372 posts 3103 karma points
    May 07, 2013 @ 13:42
    Rune Grønkjær
    0

    Then I think I will need to see it to make any conclusions.

    Sounds weird, but it probably isn't :)

    Or maybe you're on to a bug or something.

    /Rune

  • Moran 285 posts 934 karma points
    May 07, 2013 @ 15:51
    Moran
    0

    If it's okay with you I will try and upload the web site to my server if your could take a look I be grateful. I will send the link to the email you gave me.

  • Rune Grønkjær 1372 posts 3103 karma points
    May 07, 2013 @ 15:51
    Rune Grønkjær
    0

    yes, please do that.

  • Moran 285 posts 934 karma points
    May 07, 2013 @ 16:30
    Moran
    0

    Rune

    I have sent you an email with the link thank you :)

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

    Found the problem.

    Your JavaScript is faulty :)

    Your line looks like this:
    jQuery('.product').on('change', 'select.productIdentifier', function ()

    {

    My line looks like this:
    jQuery('body').on('change', '.product select.productIdentifier', function () {

    A small but very significant difference with the initial select. Your select of .product is giving you problems. When the variant is changed, the entire .product element is removed from the DOM and replaced by a new .product. That means that the .product element you selected with jQuery no longer exists, and the event is no longer active.

    When selecting body (or something else that is not removed from the DOM) it will keep on working.

    /Rune

  • Moran 285 posts 934 karma points
    May 08, 2013 @ 08:31
    Moran
    0

    Thank you very much, you have helped me a lot :) :) now it's working.

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

    No problem. Glad to help and feel free to ask again another time.

    Looking forward to see your finished website.

    /Rune

  • Moran 285 posts 934 karma points
    May 08, 2013 @ 08:48
    Moran
    0

    Yeh me too :) 

Please Sign in or register to post replies

Write your reply to:

Draft