Copied to clipboard

Flag this post as spam?

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


  • Lewis Smith 192 posts 577 karma points c-trib
    Dec 13, 2017 @ 15:23
    Lewis Smith
    0

    Marketing Discount tool not displaying discount in basket.

    Hi All,

    I'm trying to set up a marketing discount item and it's not working. If anyone could point me the right direction that would be great!

    Here is a screenshot of what I have set up in Umbraco Tea Commerce:

    enter image description here

    And here is the code that I have on that page. ( I have tried copying and pasting in the code from the Tea Commerce demo at demo.teacommerce but this doesnt show the discount as well...

    @using TeaCommerce.Api.Models
    @using TeaCommerce.Umbraco.Web
    @inherits UmbracoTemplatePage
    @{
        Layout = "CartStepMaster.cshtml";
    
        IPublishedContent currentPage = Model.Content;
        IPublishedContent nextStep = currentPage.Children.FirstOrDefault();
    
        long storeId = long.Parse(currentPage.GetPropertyValue<string>("store", true));
    
        Order order = TC.GetCurrentOrder(storeId, false);
        var classPadding = order != null && order.OrderLines.Any() ? "padded-bottom" : "padded";
    }
    @if (order != null && order.OrderLines.Any())
    {
        <section class="basket-section padded-top">
            <div class="wrap wrap-large">
                <ul>
                    <li>
                        <a href="#" class="is-active">Basket</a>
                    </li>
                    <li>
                        <a href="#">Information</a>
                    </li>
                    <li>
                        <a href="#">Shipping/Payment</a>
                    </li>
                    <li>
                        <a href="#">Accept</a>
                    </li>
                    <li>
                        <a href="#">Payment</a>
                    </li>
                    <li>
                        <a href="#">Confirmation</a>
                    </li>
                </ul>
            </div>
        </section>
    }
    <section class="basket @classPadding">
        <div class="wrap wrap-large">
            <div class="basket-wrapper">
                 @if (order != null && order.OrderLines.Any())
                 {
                    var totalPrice = order.TotalPrice.WithPreviousDiscounts.Value != order.TotalPrice.Value.Value ? order.TotalPrice.WithPreviousDiscounts.ToString() : order.TotalPrice.ToString();
                    <table>
                        <thead>
                            <tr>
                                <th>Product</th>
                                <th>Quantity</th>
                                <th>Total</th>
                                <th>Delete</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (OrderLine orderLine in order.OrderLines)
                            {
                                IPublishedContent productContent = Umbraco.TypedContent(orderLine.ProductIdentifier);
                                var unitPrice = orderLine.UnitPrice.Discount.Value > 0M ? orderLine.UnitPrice.WithoutDiscounts : orderLine.UnitPrice.Value;
                                var totalProductPrice = orderLine.TotalPrice.Discount.Value > 0M ? orderLine.TotalPrice.WithPreviousDiscounts : orderLine.TotalPrice.Value;
                                var title = !string.IsNullOrEmpty(productContent.GetPropertyValue<string>("title")) ? productContent.GetPropertyValue<string>("title") : orderLine.Name;
                                var image = productContent.GetPropertyValue<IPublishedContent>("mainImage");
                                var desc = "Nullam sit amet mi efficitur, consectetur nulla mattis, pulvinar dolor. Vivamus pulvinar accumsan odio vitae pretium. Fusce blandit gravida urna. Maecenas vulputate ligula eget ex cursus, lacinia posuere sem iaculis. Nullam volutpat porttitor ultrices. Nulla sodales, neque eu fringilla lobortis, diam nisi molestie metus, non posuere ex massa vel nulla. Nullam sit amet mi efficitur, consectetur nulla mattis, pulvinar dolor. Vivamus pulvinar accumsan odio vitae pretium. Fusce blandit gravida urna. Maecenas vulputate ligula eget ex cursus, lacinia posuere sem iaculis. Nullam volutpat porttitor ultrices. Nulla sodales, neque eu fringilla lobortis, diam nisi molestie metus, non posuere ex massa vel nulla.";
                                <tr>
                                    <td>
                                        <div class="product-info">
                                            <img src='@image.GetCropUrl("Basket Product Image")' alt="Image for @title" />
                                            <h4>@title</h4>
                                            @if (!string.IsNullOrEmpty(desc))
                                            {
                                                <p>@desc.Truncate(300)</p>
                                            }
                                        </div>
                                    </td>
                                    <td>@orderLine.Quantity.ToString("0.####")</td>
                                    <td>
                                        <p class="old-price">@orderLine.UnitPrice.WithoutDiscounts</p>
                                        <p>@orderLine.UnitPrice.Value</p>
                                    </td>
                                    <td>
                                        <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"><i class="delete"></i></button>
                                        </form>
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                    <div class="basket-item one-three">
                        @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="js-validate">
                            <input name="AddDiscountCode" value="code" type="hidden" />
                            <input name="AddGiftCard" value="code" type="hidden" />
                            <input name="storeId" value="@storeId" type="hidden" />
                            <input name="code" value="" type="text" placeholder="Enter your discount code" required="" />
                            <input value="Submit" type="submit" />
                        </form>
                    </div>
                    <div class="basket-item two-three">
                        <h3>Totals:</h3>
                        <ul>
                            @if (order.ShipmentInformation.ShippingMethodId != null)
                            {
                                ShippingMethod shippingMethod = TC.GetShippingMethod(storeId, order.ShipmentInformation.ShippingMethodId.Value);
                                var shippingMethodContent = order.ShipmentInformation.TotalPrice.WithoutDiscounts.Value != order.ShipmentInformation.TotalPrice.Value.Value ? order.ShipmentInformation.TotalPrice.WithoutDiscounts : order.ShipmentInformation.TotalPrice.Value;
                                <li>
                                    <p><strong>Shipping (@shippingMethod.Name): </strong>@shippingMethodContent</p>
                                </li>
                            }
                            @if(order.ShipmentInformation.TotalPrice.WithoutDiscounts.Value != order.ShipmentInformation.TotalPrice.Value.Value)
                            {
                                ShippingMethod shippingMethod = TC.GetShippingMethod(storeId, order.ShipmentInformation.ShippingMethodId.Value);
                                var shippingMethodContent = order.ShipmentInformation.TotalPrice.WithoutDiscounts.Value != order.ShipmentInformation.TotalPrice.Value.Value ? order.ShipmentInformation.TotalPrice.WithoutDiscounts : order.ShipmentInformation.TotalPrice.Value;
                                <li>
                                    <p><strong>Shipping Discount: </strong>@shippingMethodContent</p>
                                </li>
                            }
                            @if (order.PaymentInformation.PaymentMethodId != null)
                            {
                                PaymentMethod paymentMethod = TC.GetPaymentMethod(storeId, order.PaymentInformation.PaymentMethodId.Value);
                                var paymentMethodContent = order.PaymentInformation.TotalPrice.WithoutDiscounts.Value != order.PaymentInformation.TotalPrice.Value.Value ? order.PaymentInformation.TotalPrice.WithoutDiscounts : order.PaymentInformation.TotalPrice.Value;
                                <li>
                                    <p><strong>Payment (@paymentMethod.Name): </strong>@paymentMethodContent</p>
                                </li>
                            }
                            @if (order.TotalPrice.GiftCardsAmount.Value > 0M)
                            {
                                <li>
                                    <p><strong>@(order.GiftCards.Count > 1 ? "Gift cards: " : "Gift card: ")</strong>@order.TotalPrice.GiftCardsAmount</p>
                                </li>
                            }
                            <li>
                                <p><strong>VAT: </strong>@order.TotalPrice.Value.VatFormatted</p>
                            </li>
                            <li>
                                <p><strong>Total Including VAT: </strong>@totalPrice</p>
                            </li>
                        </ul>
                    </div>
                    <nav class="padded-top">
                        <ul>
                            <li>
                                <a href="" disabled="disabled">Back</a>
                            </li>
                            <li>
                                <a href="@nextStep.Url">Continue</a>
                            </li>
                        </ul>
                    </nav>
                 }
                 else
                 {
                     <div class="basket-item">
                         <h2>Your basket is empty</h2>
                         <p>Why not take a look at some of our favorite products...</p>
                         <ul>
                             <li>
                                 <a href="#">Rolex Watches</a>
                             </li>
                             <li>
                                 <a href="#">Tag Watches</a>
                             </li>
                         </ul>
                     </div>
                 }
            </div>
        </div>
    </section>
    

    Lewis

  • Brian Lyk Larsen 19 posts 259 karma points
    Dec 15, 2017 @ 09:48
    Brian Lyk Larsen
    0

    Hi Lewis,

    You need to add one or more rules that specify which orderlines your award should be applied to.

    You could for example add a product rule that applies the award to all products in the Rolex category.

    Something like this would give a 50% discount on all Expensive Yachts: enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft