Copied to clipboard

Flag this post as spam?

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


  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Oct 18, 2012 @ 14:49
    Rasmus Fjord
    0

    A bug when I Save an orderline through teacommerces API

    Hey Tom :) 

    Ive encountered a bug when i was doing this : 

    http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/35328-Is-it-possible-to-reduce-the-whole-order-price?p=1#comment128986

    Just to get you up to speed, ive created a discount button that gives the customer an option to put a discount upon an order. 

    I do this through Teacommerce's .net API by doing so : 

     Order o = Order.GetOrder(OrderId);
    OrderLine ol = o.CreateUniqueOrderLine(DiscountNodeId, 1);
                        ol.UnitPrice -= Discount;
    
                        o.Save();

    And as soon as i hit .save it adds a line to the order but its not saving an orderline with discount but an orderline with a unitprice of "0".

    Ive just spend an hour on the phone with Anders from Teacommerce and we been through all of the code, and we figured out that by deleting your dll it works. 

    So when we hit save some event your subscribing to in the pricebreak package is being hit and return an order value of zero.

  • Tom Smith 98 posts 172 karma points
    Oct 18, 2012 @ 15:41
    Tom Smith
    0

    Hi Rasmus,

    Ah, this is a bigger issue, and one I have no idea how to get around. 

    Basically, I subscribe to the WebshopEvents.OrderLineAdded event which is fired whenever the quantity on an order line is changed. (And therefore when an order line is added - as the quantity is updated to 1 etc etc)

    In order to work out how to update the unit price, I need to have some idea of what the original unit price was - before it was modified by applying a price break. This way - if the user reduces their quantity, the correct price break continues to be applied, until the original price is applied below the first price break threshold. 

    The only place where the unmodified unit price exists is in the product umbraco node. So this is where I'm getting it from.

    As your DiscountProductNode has (im guessing) a price of 0 in the umbraco backoffice, this is being returned. 

    Not sure how to fix this one. Perhaps a line in the config that will enable the user to exclude certain product node type aliases or product node ids from the logic?

    Tom

  • Tom Smith 98 posts 172 karma points
    Oct 18, 2012 @ 15:45
    Tom Smith
    0

    Or even simpler - rather than a list of ids to exclude - what about a checkbox on the product node called excludeFromPriceBreaks (with a config line for the property alias of course).

    In the install instructions I will mention that users need to add this property to their product doctype if they want to use it. 

    Tom

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Oct 18, 2012 @ 15:46
    Rasmus Fjord
    0

    Jup your right 0 is the node price

    well if you say you *only subscribe to quantity change i could just create a new order line. 

    save it.

    find it again, change price and save it again, or would that also fire the event ? 

     

    Maybe Anders can comment/throw a bone ?

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Oct 18, 2012 @ 15:49
    Rasmus Fjord
    0

    Arh Yes

    that would actually work !

  • Tom Smith 98 posts 172 karma points
    Oct 18, 2012 @ 15:51
    Tom Smith
    0

    Yes, that sounds like it would work,

    I'm still going to add the ability to exclude certain NodeTypeAlias's and individual nodes (via the checkbox) as I think it's a useful feature - so this will solve the issue without you having to change your logic,

    Many Thanks,

    Tom

     

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Oct 18, 2012 @ 15:52
    Rasmus Fjord
    0

    This also works ! 

                        OrderLine ol = o.CreateUniqueOrderLine(DiscountNodeId, 1);
                        o.Save();
                        long id = ol.Id;
                        o = Order.GetOrder(OrderId);
                        o.OrderLines.First(x => x.Id == id).UnitPrice -= Discount;
                        o.Save();
  • Tom Smith 98 posts 172 karma points
    Oct 19, 2012 @ 19:52
    Tom Smith
    0

    Hi Rasmus,

    Not sure if you managed to sort this or not, but the updates in the other thread

    http://our.umbraco.org/projects/backoffice-extensions/cogworks-price-breaks-for-tea-commerce/bugs-issues-questions/35163-In-need-to-update-the-quantity-after-AddOrderLine

    Should help without you having to alter your logic,

    Many Thanks,

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft