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 213 posts 300 karma points c-trib
    Apr 21, 2020 @ 20:04
    Tom Madden
    0

    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 2469 posts 12071 karma points MVP 6x c-trib
    Apr 22, 2020 @ 07:55
    Matt Brailsford
    0

    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?

    Matt

  • Tom Madden 213 posts 300 karma points c-trib
    Apr 22, 2020 @ 20:00
    Tom Madden
    0

    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

    t

    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

        <div class="col col-lg-6 col-md-5 col-sm-4">
          Product
        </div>
        <div class="col col-sm-2">
          Unit price
        </div>
        <div class="col col-lg-2 col-md-3 col-sm-4 text-center">
          Quantity
        </div>
        <div class="col col-sm-2 text-right">
          Total
        </div>
      </div>
      <div class="orderlines">
        @foreach ( OrderLine orderLine in order.OrderLines ) {
          IPublishedContent productContent = Umbraco.TypedContent( orderLine.ProductIdentifier );
            <div class="row orderline">
                <div class="col col-lg-6 col-md-5 col-sm-4">
                    @{
                        var image = Umbraco.TypedContent(orderLine.ProductIdentifier).GetPropertyValue<IEnumerable<IPublishedContent>>("image")?.FirstOrDefault();
                        if (image != null)
                        {
                            <img class="cart-icon" src="@image.GetCropUrl("icon")" data-src="@image.GetCropUrl("icon")" alt="@(image.GetPropertyValue<string>("altText"))">
                        }
                    }
                    <span class="hidden-sm hidden-md hidden-lg">Product: </span>@orderLine.Name
                </div>
                <div class="col col-sm-2">
                    <span class="xs-right">
                        @if (orderLine.UnitPrice.Discount.Value > 0M)
                        {
                            <text>(</text>
                            <s>@orderLine.UnitPrice.WithoutDiscounts</s>
                            <text>)</text>
                        }
                        @orderLine.UnitPrice.Value
                    </span>
                    <span class="hidden-sm hidden-md hidden-lg xs-left">Unit price: </span>
                </div>
                <div class="col col-lg-2 col-md-3 col-sm-4 quantity text-center cart1">
                    <span class="hidden-sm hidden-md hidden-lg">Quantity: </span>
                    <div class="input-group">
                        <form action="/base/TC/FormPost.aspx" method="post">
                            <input name="storeId" type="hidden" value="@storeId"/>
                            <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity, overwriteQuantity : overwriteQuantity"/>
                            <input name="overwriteQuantity" type="hidden" value="true"/>
                            <input name="orderLineId" type="hidden" value="@orderLine.Id"/>
                            <input type="number" name="quantity" class="form-control" value="@orderLine.Quantity.ToString("0.####")" pattern="[0-9]*" min="1"/>
                        </form>
                        <form action="/base/TC/FormPost.aspx" method="post">
                            <input name="storeId" type="hidden" value="@storeId"/>
                            <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity"/>
                            <input name="orderLineId" type="hidden" value="@orderLine.Id"/>
                            <input name="quantity" type="hidden" value="-1"/>
                            <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-minus"></span></button>
                        </form>
                        <form action="/base/TC/FormPost.aspx" method="post">
                            <input name="storeId" type="hidden" value="@storeId"/>
                            <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity"/>
                            <input name="orderLineId" type="hidden" value="@orderLine.Id"/>
                            <input name="quantity" type="hidden" value="1"/>
                            <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span></button>
                        </form>
                        <form action="/base/TC/FormPost.aspx" method="post">
                            <input name="RemoveOrderLine" type="hidden" value="orderLineId : orderLineId"/>
                            <input name="storeId" type="hidden" value="@storeId"/>
                            <input name="orderLineId" type="hidden" value="@orderLine.Id"/>
                            <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span></button>
                        </form>
    
                    </div>
                </div>
                <div class="col col-sm-2 text-right">
                    <span class="xs-right">
                        @if (orderLine.TotalPrice.Discount.Value > 0M)
                        {
                            <text>(</text>
                            <s>@orderLine.TotalPrice.WithPreviousDiscounts</s>
                            <text>)</text>
                        }
                        @orderLine.TotalPrice.Value
                    </span>
                    <span class="hidden-sm hidden-md hidden-lg xs-left">Total price: </span>
                </div>
            </div>
        }
      </div>
      <div class="row">
        <div class="col col-sm-10 col-xs-8 text-right">
          Subtotal
        </div>
        <div class="col col-sm-2 col-xs-4 text-right">
          @if ( order.SubtotalPrice.Discount.Value > 0M ) {
            <text>(</text>
            <s>@order.SubtotalPrice.WithPreviousDiscounts</s>
            <text>)</text>
          }
          @order.SubtotalPrice.Value
        </div>
      </div>
      @if ( order.ShipmentInformation.ShippingMethodId != null ) {
        ShippingMethod shippingMethod = TC.GetShippingMethod( storeId, order.ShipmentInformation.ShippingMethodId.Value );
        <div class="row">
          <div class="col col-sm-10 col-xs-8 text-right">
            Shipping (@shippingMethod.Name)
          </div>
          <div class="col col-sm-2 col-xs-4 text-right">
              @if (order.ShipmentInformation.TotalPrice.WithoutDiscounts.Value != order.ShipmentInformation.TotalPrice.Value.Value)
              {
                  <text>(</text>
                  <s>@order.ShipmentInformation.TotalPrice.WithoutDiscounts</s>
                  <text>)</text>
              }
               @(order.ShipmentInformation.TotalPrice.Value.FormattedWithoutSymbol != "0.01" ? order.ShipmentInformation.TotalPrice.Value.WithVatFormatted : "TBC")
          </div>
        </div>
      }
      @*@if ( order.PaymentInformation.PaymentMethodId != null ) {
        PaymentMethod paymentMethod = TC.GetPaymentMethod( storeId, order.PaymentInformation.PaymentMethodId.Value );
        <div class="row">
          <div class="col col-sm-10 col-xs-8 text-right">
            Payment (@paymentMethod.Name)
          </div>
          <div class="col col-sm-2 col-xs-4 text-right">
            @if ( order.PaymentInformation.TotalPrice.WithoutDiscounts.Value != order.PaymentInformation.TotalPrice.Value.Value ) {
              <text>(</text>
              <s>@order.PaymentInformation.TotalPrice.WithoutDiscounts</s>
              <text>)</text>
            }
            @order.PaymentInformation.TotalPrice.Value
          </div>
        </div>
      }*@
      @if ( order.TotalPrice.GiftCardsAmount.Value > 0M ) {
        <div class="row">
          <div class="col col-sm-10 col-xs-8 text-right">
            @(order.GiftCards.Count > 1 ? "Gift cards" : "Gift card")
          </div>
          <div class="col col-sm-2 col-xs-4 text-right">
            -@order.TotalPrice.GiftCardsAmount
          </div>
        </div>
      }
      <div class="row">
        <div class="col col-sm-10 col-xs-8 text-right">
          Total
        </div>
        <div class="col col-sm-2 col-xs-4 text-right">
          @if ( order.TotalPrice.WithPreviousDiscounts.Value != order.TotalPrice.Value.Value ) {
            <text>(</text>
            <s>@order.TotalPrice.WithPreviousDiscounts</s>
            <text>)</text>
          }
          @order.TotalPrice
        </div>
      </div>
      @*<div class="row">
        <div class="col col-sm-10 col-xs-8 text-right">
          VAT
        </div>
        <div class="col col-sm-2 col-xs-4 text-right">
          @order.TotalPrice.Value.VatFormatted
        </div>
      </div>*@
    </div>
    
    <div class="discountCodes">
      @if ( order.DiscountCodes.Any() ) {
        <p>Your discount codes: @string.Join( ", ", order.DiscountCodes.Select( d => "\"" + d.Code + "\"" ) )</p>
      }
    
      <h3>Have a discount code?</h3>
    
      <form method="post" action="/base/TC/FormPost.aspx" class="form-inline form-autoValidate">
        <input name="AddDiscountCode" value="code" type="hidden" />
        <input name="AddGiftCard" value="code" type="hidden" />
        <input name="storeId" value="@storeId" type="hidden" />
        <div class="form-group">
          <input name="code" value="" type="text" placeholder="Enter your discount code" class="form-control" required="" />
        </div>
        <input value="Add discount code" class="btn btn-default" type="submit" />
      </form>
    </div>
    <nav class="navbar">
      <a href="@nextStep.Url" class="btn btn-success">Continue</a>
      <a disabled="disabled" class="btn btn-default">Back</a>
    </nav>
    

    }

  • Matt Brailsford 2469 posts 12071 karma points MVP 6x c-trib
    Apr 23, 2020 @ 09:25
    Matt Brailsford
    0

    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?

    Matt

  • Tom Madden 213 posts 300 karma points c-trib
    26 days ago
    Tom Madden
    0

    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 2469 posts 12071 karma points MVP 6x c-trib
    25 days ago
    Matt Brailsford
    0

    Glad you were able to find a solution 👍

Please Sign in or register to post replies

Write your reply to:

Draft