Copied to clipboard

Flag this post as spam?

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


  • Rehan Zahid 31 posts 52 karma points
    Dec 13, 2012 @ 01:48
    Rehan Zahid
    0

    Error when updating OrderLineProperties

    Hi Rune & Anders,

    i have followed your instruction but i am receiving an annoying error, and my date would not be added.. below is my code

    var orderline = TeaCommerce.getOrder();
        for (var i = 0; i < TeaCommerce.getOrder().OrderLines.length; i++) {

            if (TeaCommerce.getOrder().OrderLines[0].Properties[3].Value == "Baker") {

                var formObjDate = {
                    "DeliveryDate": jQuery('#datepickerBaker').val(),
                    "DeliveryTime": jQuery('#datepickerBaker').val()
                };
            }

            else {

                var formObjDate = {
                    "DeliveryDate": jQuery('#datepickerOther').val(),
                    "DeliveryTime": jQuery('#datepickerOther').val()
                };
            }

            TeaCommerce.updateUniqueOrderLineProperties(TeaCommerce.getOrder().OrderLines[i].Id, formObjDate);
        }

        window.location.href = jQuery(this).attr('link');
        return false;

    This what is included in my method TeaCommerce.updateUniqueOrderLineProperties(452, formObjDate);
    I have followed this TeaCommerce.updateUniqueOrderLineProperties(orderLineId, propertyList, settings) 

    I have also tried this TeaCommerce.updateUniqueOrderLineProperties(TeaCommerce.getOrder().OrderLines[i].NodeId, TeaCommerce.getOrder().OrderLines[i].Id, formObjDate, false);

    And i am receiving this error, what i am doing wrong...?

  • Rune Grønkjær 1371 posts 3102 karma points
    Dec 13, 2012 @ 08:37
    Rune Grønkjær
    0

    Hi Rehan,

    Well there's a bunch of stuff wrong there :)

    1. Don't call getOrder that many times. It will make a server call and fetch the order from the server. It's fast, but not that fast.
    2. Write the "Baker" property into your html as an attribute on your orderline tr. Just like the order line id is.
    3. Actually you don't need to call get order at all! Instead get the order lines directly from the DOM. Something ilke this:

    var orderLines = jQuery('#cartContent .orderLine'),
         dateBaker = jQuery('#datepickerBaker').val(),
         date = jQuery('#datepickerOther).val();
    orderLines.each(function(){
      var orderLine = jQuery(this),
          orderLineId = orderLine.attr('orderlineid'),
           isBaker = orderLine.attr('baker') == "Baker";

            if (isBaker) {

                var formObjDate = {
                    "DeliveryDate": dateBaker,
                    "DeliveryTime": dateBaker
                };
            }

            else {

                var formObjDate = {
                    "DeliveryDate": date,
                    "DeliveryTime": date
                };
            }


      TeaCommerce.updateUniqueOrderLineProperties(orderLineId, 'date');
    });

    Don't know if this is precise, but you will need to do something like that. Please use firebugs console to check what is actually sent to the server. That way you can see if it does what you want to.

    /Rune

  • Rehan Zahid 31 posts 52 karma points
    Dec 13, 2012 @ 09:52
    Rehan Zahid
    0

    but i am only calling getOrder just once...

    I have made a little change instead of adding datepicker on step 4 i have added on step 3 "levering" instead, so when i try to call this  jQuery('#cartContent .orderLine') the length is 0...

    how can i access OrderLine from step 3...

    By the way thx for all that good service you are providing... :) 

  • Rune Grønkjær 1371 posts 3102 karma points
    Dec 13, 2012 @ 10:50
    Rune Grønkjær
    0

    Ok. Then you will have to use getOrder and loop the order lines there instead. :)

    /Rune

  • Rehan Zahid 31 posts 52 karma points
    Dec 13, 2012 @ 11:18
    Rehan Zahid
    0

    but i am still receiving the error... :(

    you have wrote TeaCommerce.updateUniqueOrderLineProperties(orderLineId, 'date'); isn't it TeaCommerce.updateUniqueOrderLineProperties(orderLineId, formObjDate);

  • Rune Grønkjær 1371 posts 3102 karma points
    Dec 13, 2012 @ 11:53
    Rune Grønkjær
    0

    Aah. Sorry. Now when I look closer I see the problem.

    updateUniqueOrderLineProperties will only work on unique orderlines, which yours is not! You need to use updateOrderLineProperties and pass along the nodeId instead.

    /Rune

  • Rehan Zahid 31 posts 52 karma points
    Dec 13, 2012 @ 12:27
    Rehan Zahid
    0

    perfect it work... you are genius... :)

  • Rune Grønkjær 1371 posts 3102 karma points
    Dec 13, 2012 @ 12:31
    Rune Grønkjær
    0

    Not genious to not throw you on a wild goose chase. But I'm glad we got it working.

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft