Close

Profile: palwinder

Avatar

User posts

Hi,

We are trying to achieve the similiar behaviour like below which is in Emporium demo.But getting Ajax cat failure error.



Here is the code from ProdctBox.cshtml

  <div class="buttons">   
                @if (!Model.ProductPrice.DisableBuyButton)
                {
                    var addToCartText = T("ShoppingCart.AddToCart").Text;
                    if (Model.ProductPrice.IsRental)
                    {
                        addToCartText = T("ShoppingCart.Rent").Text;
                    }
                    if (Model.ProductPrice.AvailableForPreOrder)
                    {
                        addToCartText = T("ShoppingCart.PreOrder").Text;
                    }
                    <div class="add-to-cart-qty-wrapper">
                        <input asp-for="EnteredQuantity" id="[email protected]" value="1" class="qty-input" type="text" aria-label=@T("Products.Qty.AriaLabel") />
                        <span class="plus">&#x69;</span>
                        <span class="minus">&#x68;</span>
                    </div>

                    <script asp-location="Footer">
                        //when a customer clicks 'Enter' button we submit the "add to cart" button (if visible)
                        $(document).ready(function () {
                            $("#@Html.IdFor(model => model.EnteredQuantity)").on("keydown", function (event) {
                                if (event.keyCode == 13) {
                                    $("#[email protected]").trigger("click");
                                    return false;
                                }
                            });

                            $("#[email protected]").on("input propertychange paste", function () {
                                var data = {
                                    productId: @Model.Id,
                                    quantity: $('#[email protected]').val()
                                };
                                $(document).trigger({ type: "product_quantity_changed", changedData: data });
                            });
                        });
                    </script>
                    <button type="button" id="[email protected]" class="button-1 add-to-cart-button" data-productid="@Model.Id" onclick="AjaxCart.addproducttocart_details('@Url.RouteUrl("AddProductToCart-Details", new {productId = Model.Id, shoppingCartTypeId = (int) ShoppingCartType.ShoppingCart})', '#product-details-form');return false;">@addToCartText</button>
                }
            </div>


Here is the error screenshot from console