Copied to clipboard

Flag this post as spam?

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


  • aaeda 113 posts 145 karma points
    Apr 21, 2020 @ 12:53
    aaeda
    0

    Hello

    I have installed Tea commerce on an existing site. Have installed the package but not the starter kit as the website already exists.

    I have followed the installation steps (creation of store, country, currency etc..) and also inspired from the starter kit to build up the cart.

    However I am having an empty cart after 'Add to basket'.

    I am unsure of the page : /base/TC/FormPost.aspx Where can it be found?

    Can anyone help please?

    thanks

  • Matt Brailsford 2644 posts 13174 karma points MVP 7x c-trib
    Apr 21, 2020 @ 12:59
    Matt Brailsford
    0

    Hi aaeda

    Can you share the code you are using to add a product to the cart? And also the code you are using to display the number of items in the cart? Also, can you check your log file to see if you are experiencing any errors.

    Many thanks

    Matt

  • aaeda 113 posts 145 karma points
    Apr 21, 2020 @ 13:02
    aaeda
    0

    Hello Matt

    Yes sure. Please see below.

    <form method="post" action="/base/TC/FormPost.aspx" class="ajaxForm" data-product-id="@productPage.Id">
        <input name="AddOrUpdateOrderLine" value="productIdentifier, quantity" type="hidden" />
    
        <input name="storeId" value="@storeId" type="hidden" />
         <input name="productIdentifier" value="@productPage.Id" type="hidden" />
                                                        <div class="form-group">
                                                          <label class="col-sm-3 control-label">Quantity</label>
                                                          <div class="col-sm-9">
                                                            <input class="form-control" name="quantity" value="1" type="text" />
                                                          </div>
                                                        </div>
                                                        <input class="btn btn-primary btn-block" value="Add to basket" type="submit" />
                                                        </form>
    

    Cannot see any error as such in the logs. Note that we are on the trial version to test everything before buying the license.

    thanks for your help.

  • Matt Brailsford 2644 posts 13174 karma points MVP 7x c-trib
    Apr 21, 2020 @ 13:06
    Matt Brailsford
    0

    Ok, that seems ok to me, and using the demo version should work fine locally so don't think that's the issue.

    The /base/TC/FormPost.aspx URL is just something that exists so you shouldn't need to worry about this.

    Just to check, you are using Umbraco v7 right? And can you share the code that you are using to render the cart?

    Many thanks

    Matt

  • aaeda 113 posts 145 karma points
    Apr 21, 2020 @ 13:11
    aaeda
    0

    Hello Matt

    Yes using umbraco version 7. For the cart, I have created the same as what's there on the demo site. please see below.

    @using TeaCommerce.Api.Models
    

    @using TeaCommerce.Umbraco.Web @inherits Umbraco.Web.Mvc.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 ); @order; } @section Cartcontent { @if ( order != null ) {

    aaaa

    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">
              <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">
              <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
          </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 incl. VAT
        </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>
    

    }

    }

    thanks

  • aaeda 113 posts 145 karma points
    Apr 21, 2020 @ 13:16
  • Matt Brailsford 2644 posts 13174 karma points MVP 7x c-trib
    Apr 21, 2020 @ 13:35
    Matt Brailsford
    0

    Hi aaeda,

    Ok, well, looking at the site you've linked to, clicking add to cart does appear to be adding products to the order as the response from this in dev tools is showing a valid cart so I think your issue is to do with your cart rendering.

    From what I can tell, navigating to your cart page, you don't appear to be rendering the cart at all. You are displaying the section headers, but I don't see any markup related to the cart markup you have referenced above anywhere in your cart page. My guess would be that this code isn't actually being used so I'd double check your templates are setup correctly and are linked to your cart page or if this code is inside a partial, make sure the partial is being rendered in your cart page template.

    Hope this helps

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft