Copied to clipboard

Flag this post as spam?

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

  • Tom Madden 253 posts 455 karma points MVP 4x c-trib
    Apr 21, 2020 @ 20:04
    Tom Madden

    Can't remove or update orderlines (orderLineId is 0 for each line)

    Suddenly orderLineId is always returning 0. Is this a result of us populating the site before applying the licence file? We've added a few thousand products recently, though only run through 4 test orders, so well within the demo limit of 20, but I can't think of another reason why this has started happening?

    many thanks Tom

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Apr 22, 2020 @ 07:55
    Matt Brailsford

    Hey Tom,

    Shouldn't be anything to do with the license file at this point.

    An orderLineId of 0 would suggest it's an order line that hasn't been persisted yet. Where exactly are you seeing the order line ids being 0? Whats your code?


  • Tom Madden 253 posts 455 karma points MVP 4x c-trib
    Apr 22, 2020 @ 20:00
    Tom Madden

    Hi Matt,

    thanks for the response. Sorry I couldn't reply earlier.

    I'm using almost the exact markup that came somewhere in the distant past from either a starter or demo site of Tea Commerce, I've included the whole file below (commented out sections and all), but I did a diff compare with the original and don't see any significant differences.

    Apart from adding products in preparation for starting to test the site we've added a few discount codes, purely using the UI. We wondered if they could be affecting this at all?

    I'm seeing the orderLineId as 0 in the hidden fields (as well as when stepping through the code), but the rest of the order line details seem correct and all those output are populated as expected.

    We're going to remove the discount codes in the meantime and I'll post an update if that's has any impact, or if I find out any other information.

    many thanks


    p.s. sorry for not formatting the code!

    @using TeaCommerce.Api.Models

    @using TeaCommerce.Umbraco.Web @inherits UmbracoTemplatePage @{ Layout = "CartStepMaster.cshtml";

    IPublishedContent currentPage = Model.Content; IPublishedContent nextStep = currentPage.Children.FirstOrDefault();

    //store id long storeId = long.Parse( currentPage.GetPropertyValue

    Order order = TC.GetCurrentOrder( storeId, false ); } @if ( order != null ) {

    Your cart

    Unit price
    @foreach ( OrderLine orderLine in order.OrderLines ) { IPublishedContent productContent = Umbraco.TypedContent( orderLine.ProductIdentifier );
    @{ var image = Umbraco.TypedContent(orderLine.ProductIdentifier).GetPropertyValue<>
    @if (orderLine.UnitPrice.Discount.Value > 0M) { @orderLine.UnitPrice.WithoutDiscounts } @orderLine.UnitPrice.Value Unit price:
    @if (orderLine.TotalPrice.Discount.Value > 0M) { @orderLine.TotalPrice.WithPreviousDiscounts } @orderLine.TotalPrice.Value Total price:
    @if ( order.SubtotalPrice.Discount.Value > 0M ) { @order.SubtotalPrice.WithPreviousDiscounts } @order.SubtotalPrice.Value
    @if ( order.ShipmentInformation.ShippingMethodId != null ) { ShippingMethod shippingMethod = TC.GetShippingMethod( storeId, order.ShipmentInformation.ShippingMethodId.Value );
    Shipping (@shippingMethod.Name)
    @if (order.ShipmentInformation.TotalPrice.WithoutDiscounts.Value != order.ShipmentInformation.TotalPrice.Value.Value) { @order.ShipmentInformation.TotalPrice.WithoutDiscounts } @(order.ShipmentInformation.TotalPrice.Value.FormattedWithoutSymbol != "0.01" ? order.ShipmentInformation.TotalPrice.Value.WithVatFormatted : "TBC")
    } @*@if ( order.PaymentInformation.PaymentMethodId != null ) { PaymentMethod paymentMethod = TC.GetPaymentMethod( storeId, order.PaymentInformation.PaymentMethodId.Value );
    Payment (@paymentMethod.Name)
    @if ( order.PaymentInformation.TotalPrice.WithoutDiscounts.Value != order.PaymentInformation.TotalPrice.Value.Value ) { @order.PaymentInformation.TotalPrice.WithoutDiscounts } @order.PaymentInformation.TotalPrice.Value
    }*@ @if ( order.TotalPrice.GiftCardsAmount.Value > 0M ) {
    @(order.GiftCards.Count > 1 ? "Gift cards" : "Gift card")
    @if ( order.TotalPrice.WithPreviousDiscounts.Value != order.TotalPrice.Value.Value ) { @order.TotalPrice.WithPreviousDiscounts } @order.TotalPrice
    @if ( order.DiscountCodes.Any() ) {

    Your discount codes: @string.Join( ", ", order.DiscountCodes.Select( d => "\"" + d.Code + "\"" ) )


    Have a discount code?


  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Apr 23, 2020 @ 09:25
    Matt Brailsford

    Hmm, I can't spot anything in this that would appear to be the problem.

    Do you have any event handlers or anything else affecting the order behind the scene? Like I say, the order line id would only ever be 0 if it is a new order line, but I don't know what would be causing it to recreate that.

    The only code we have that I think could be linked is if your order is finalized, or has gone through to the payment gateway, it will be flagged as "uneditable" at which point if you try to modify that order, TC will clone it, so maybe those order lines are new, because it's been cloned?


  • Tom Madden 253 posts 455 karma points MVP 4x c-trib
    Apr 30, 2020 @ 18:49
    Tom Madden

    Turns out there was an issue in a custom shipping calculation, which was related to when the order amount was more than a value which was also being set up in a discount code so it looked like it was related to the discount code. No ysod and nothing in Event Viewer, but I'll know next time something similar happens. cheers t

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    May 01, 2020 @ 09:57
    Matt Brailsford

    Glad you were able to find a solution 👍

Please Sign in or register to post replies

Write your reply to: