Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    Jul 08, 2011 @ 16:01
    Matt Taylor
    0

    Am I using CreateUniqueOrderLine correctly?

    I was playing with CreateUniqueOrderLine in V1.4.1 beta and got some funny results when viewing the cart content with cartStep01.xslt.

    If I call the code below a couple of times:

    TeaCommerce.Data.Order order = TeaCommerce.Razor.TeaCommerce.GetOrder();
    OrderLine newOrderLine = order.CreateUniqueOrderLine(Node.getCurrentNodeId(), 1);
    order.Save();

    The product is displayed twice as expected but I noticed that the VAT amounts were not being updated correctly.

    I also found that changing the quantities or trying to delete an orderline caused things to go even more wrong.

  • Anders Burla 2560 posts 8256 karma points
    Jul 08, 2011 @ 19:32
    Anders Burla
    0

    Hi Matt

    Thanks for testing the .NET part and all it corner cases :) We will try and look into it. Could you try and write the specific cases that you tested and what you think is wrong with the output or data?

    Thanks mate

  • Matt Taylor 873 posts 2086 karma points
    Jul 11, 2011 @ 11:04
    Matt Taylor
    0

    I'm having trouble with my 'Event' product which inherits from the standard 'Product' doc type.

    If I navigate to my 'Event' product page and add it to the basket using the following code in my .Net control

    TeaCommerce.Data.Order order =TeaCommerce.Razor.TeaCommerce.GetOrder();
    OrderLine newOrderLine = order.CreateUniqueOrderLine(Node.getCurrentNodeId(),1);
    order
    .Save();

    all appears fine when I display the cart contents.

    I navigate back to the 'Event' product page and repeat the process

    all still seems fine (although when I did this on Friday the cart totals seemed a little messed up.

    I clicked 'Delete' on the 2nd item but this had no effect.

    I then tried reducing the quantity to 0 of the 1st orderline and although this did update all the totals, it continued to show two items.

    I then refreshed the page to find that 3 items were now being displayed, one of them with a negative quantity.

    So the question is, am I doing something wrong when calling CreateUniqueOrderLine or is there a bug?

    Regards,

    Matt

  • Anders Burla 2560 posts 8256 karma points
    Jul 11, 2011 @ 11:09
    Anders Burla
    0

    Hi Matt

    Thanks for info - we will look into it

  • Rune Grønkjær 1372 posts 3103 karma points
    Jul 11, 2011 @ 11:38
    Rune Grønkjær
    0

    Hi Matt,

    You're having problems because the Starter Kit assumes the orderlines are NOT unique. You will have to change a few details in you teacommerce_advanced.js file. Mind you that I could not test the code below, but it should work... in theory :)

    Plus/minus functionality will be changed to this:

    /* UPDATE ORDERLINE QUANTITY */
    jQuery('.minus, .plus').live('click'function () {
      var button = jQuery(this),
          orderlineEle = button.closest('.orderLine'),
          orderlineid = orderlineEle.attr('orderlineid'),
          productId = orderlineEle.attr('nodeid'),
          changeQuantity = 1;
      //Plus and minus will increase or decrease the quantity by one
      if (button.hasClass('minus')) {
        changeQuantity = -1;
      }
      //Using addOrderLine we count the orderline quantity up or down
      TeaCommerce.addUniqueOrderLine(productId, orderlineid, changeQuantity, truefunction (data) {
        //When the server answers we update the specific orderline
        if (data.OrderLinesUpdated[0]) {
          updateOrderLineInUI(orderlineEle, data.OrderLinesUpdated[0]);
        }
      });
      return false;
    });

    Removing the unique orderline will need to look something like this:

    /* REMOVE ORDERLINE */
    jQuery('.remove').live('click'function () {
      var button = jQuery(this),
          orderlineEle = button.closest('.orderLine'),
          orderlineid = orderlineEle.attr('orderlineid'),
          productId = orderlineEle.attr('nodeid');
      //We use removeOrderLine to remove the orderline on the server
      TeaCommerce.removeUniqueOrderLine(orderlineid, truefunction () {
        //When the server answers we update the orderline in the UI
        removeOrderLineFromUI(orderlineEle);
      });
    });

    That should do the trick.

    /Rune

  • Anders Burla 2560 posts 8256 karma points
    Jul 12, 2011 @ 13:44
    Anders Burla
    0

    Hi Matt

    Did you manage to get it working?

  • Matt Taylor 873 posts 2086 karma points
    Jul 12, 2011 @ 14:42
    Matt Taylor
    0

    Hi Anders & Rune,

    Yes, it works OK with the new script for anything added with CreateUniqueOrderLine although doesn't now work of course with anything added with CreateOrderLine such as Product A1 on the homepage from the starter kit but I guess you can't have it both ways. ;)

    In general though there seems to be a refreshing problem with the cart-content page from the multilanguage starter kit.
    Add Product A1 from the homepage for example, then go to the cart-content page, click delete or reduce the quantity and the all the totals will be updated to 0 but the item will still be displayed in the list until you refresh the page.

    This doesn't really pose much of a problem for me as I will probably be creating my own control to render the cart contents, but at least I know that I'm using CreateUniqueOrderLine correctly rather than thinking I was creating a problem I'd have ot deal with later.

    Regards,

    Matt

  • Rune Grønkjær 1372 posts 3103 karma points
    Jul 12, 2011 @ 14:48
    Rune Grønkjær
    0

    That's good. Most of it anyways. I'm sure it's a minor javascript thing going wrong in the cart.

    You can actually have both unique and non unique orderlines in the cart at the same time. They will just need updating in different ways. I will soon be updating the Starter Kit and Multilanguage Kit to support both methods. Then I will see if there's anything that could be done easier or better.

    /Rune

  • Matt Taylor 873 posts 2086 karma points
    Jul 12, 2011 @ 14:54
    Matt Taylor
    0

    Thanks Rune.

Please Sign in or register to post replies

Write your reply to:

Draft