Problem with Gift Card

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anni tempo fa
When I try to add a new gift card it will display fine but when I try to purchase the card and I get to the section where I fill in the name, e-mail address etc. I get the following

enter valid recipient name, enter valid recipient email, enter valid sender name, enter valid sender e-mail

The default cards work just fine.

I tried to copy a card and use that and I got the same error...

Any suggestions?
12 anni tempo fa
What version are you using? There was an issue in the previous version (fixed in 2.50). Gift cards didn't work with a “Single product variant” product template in case if a product identifier was different to a product variant identifier.
12 anni tempo fa
I am using 2.5. Also when all I did was copy one of the sample gift cards and changed nothing I am getting the same error.
12 anni tempo fa
Just tested. Everything works fine. Are you using any custom themes? Have you modified the source code (views)?
12 anni tempo fa
Custom theme is yes. Shop all theme. Modify source code no
12 anni tempo fa
Please post the following file of your custom theme here: \Themes\YourThemeName\Views\Catalog\ProductTemplate.SingleVariant.cshtml
12 anni tempo fa
Sorry but I do not see the file...
12 anni tempo fa
Never mind. I realize you mean for me to copy the file from the site to the forum.  I read it the other way.

Here is the code.

@model ProductModel
@using Nop.Core;
@using Nop.Core.Domain.Common;
@using Nop.Core.Infrastructure;
@using Nop.Web;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title, meta
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var productUrl = Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(productUrl);
    }
}
@{
    var defaultProductVariant = Model.ProductVariantModels.Count > 0 ? Model.ProductVariantModels[0] : null;

    //errors
    var errors = new List<string>();
    foreach (var modelState in ViewData.ModelState.Values)
    {
        foreach (var error in modelState.Errors)
        {
            errors.Add(error.ErrorMessage);
        }
    }
}
@if (errors.Count > 0)
{
    var addToCartWarningsSb = new System.Text.StringBuilder();
    for (int i = 0; i < errors.Count; i++)
    {
        addToCartWarningsSb.Append(errors[i]);
        if (i != errors.Count - 1)
        {
            addToCartWarningsSb.Append("\\n");
        }
    }

    //display errors  
    <script type="text/javascript">
        $(document).ready(function () {
            alert('@Html.Raw(addToCartWarningsSb.ToString())');
        });
    </script>
}

@{
    var shopAllThemeSettings = ViewBag.ShopAllThemeSettings;
}

<script type="text/javascript">

    $(document).ready(function () {

        $("#addProductToWishListLink").click(function () {

            var submitButton = $("<input name='addtowishlist-@(defaultProductVariant.Id)' />");
            $(this).closest("form").append(submitButton);
            $(this).closest("form").submit();
        });

    });

</script>

<!--product breadcrumb-->

@section ProductBreadCrumb
{
    @Html.Action("ProductBreadcrumb", "Catalog", new { productId = Model.Id })
}
<div class="clear">
</div>
<div class="product-details-page">
    @*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@
    @using (Html.BeginRouteForm("Product", new { productId = Model.Id, SeName = Model.SeName }, FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        <div class="product-essential">
            <div class="product-details-info">
                <!--product pictures-->
                @Html.Partial("_ProductDetailsPictures", Model)
                <div class="overview">
                    <h1 class="productname">
                        @Model.Name
                    </h1>
                    <div class="shortdescription">
                        @Html.Raw(Model.ShortDescription)
                    </div>
                    <div class="clear">
                    </div>
                    @{
                        var dataDictPrice = new ViewDataDictionary();
                        dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", defaultProductVariant.Id);
                                                        @Html.Partial("_ProductVariantPrice", defaultProductVariant.ProductVariantPrice, dataDictPrice)
                    }

                    @{
                        MvcHtmlString productVariantSkuManStock = Html.Partial("_ProductVariant_SKU_Man_Stock", defaultProductVariant);
                        MvcHtmlString productVariantBackInStockSubscription = Html.Partial("_ProductVariantBackInStockSubscription", defaultProductVariant);
                        MvcHtmlString productManufacturers = Html.Action("ProductManufacturers", "Catalog", new { productId = Model.Id });

                        MvcHtmlString productReviewOverview = MvcHtmlString.Empty;
                        
                        if(shopAllThemeSettings == null || !shopAllThemeSettings.ShopAllThemePluginsSettings.IntegrateNopQuickTabs)
                        {
                            productReviewOverview = Html.Action("ProductReviewOverview", "Catalog", new { productId = Model.Id });
                        }
                        
                        MvcHtmlString downloadSample = Html.Partial("_DownloadSample", defaultProductVariant);
                    }

                    <div class="details">
                        <ul>
                            @if (!MvcHtmlString.IsNullOrEmpty(productVariantSkuManStock))
                            {
                                <li>
                                    <!--product SKU, manufacturer part number, stock info-->
                                    @productVariantSkuManStock
                                </li>
                            }
                            
                            @if (!MvcHtmlString.IsNullOrEmpty(productVariantBackInStockSubscription))
                            {
                                <li>
                                    <!--Back in stock subscription-->
                                    @productVariantBackInStockSubscription
                                </li>
                            }
                            
                            @if (!MvcHtmlString.IsNullOrEmpty(productManufacturers))
                            {  
                                <li>
                                    <!--product manufactures-->
                                    @productManufacturers
                                </li>
                            }
                            
                            @if (!MvcHtmlString.IsNullOrEmpty(productReviewOverview))
                            {
                                <li>
                                    <!--product reviews-->
                                    @productReviewOverview
                                </li>
                            }
                            
                            @if (!MvcHtmlString.IsNullOrEmpty(downloadSample))
                            {
                                <li>
                                    <!--sample download-->
                                    @downloadSample
                                </li>
                            }
                            @if (!defaultProductVariant.AddToCart.DisableWishlistButton)
                            {
                                <li>
                                    @*<input type="submit" name="addtowishlist-@(defaultProductVariant.Id)" class="productVariantAddToWishlistLink" value="@T("ShoppingCart.AddToWishlist")" />*@
                                    <a id="addProductToWishListLink">@T("ShoppingCart.AddToWishlist")</a>
                                </li>
                            }
                            <li>
                                <a onclick="setLocation('@Url.RouteUrl("ProductEmailAFriend", new { productId = Model.Id })')">@T("Products.EmailAFriend")</a>
                            </li>
                            <li>
                                <a onclick="setLocation('@Url.RouteUrl("AddProductToCompare", new { productId = Model.Id })')">@T("Products.Compare.AddToCompareList")</a>
                            </li>
                        </ul>
                    </div>
                    <div class="add-to-cart">
                        @{
                            
                            var dataDictAddToCart = new ViewDataDictionary();
                            dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", defaultProductVariant.Id);
                                            
                            dataDictPrice.Add("ShopAllThemeSettings", ViewBag.ShopAllThemeSettings);
                            @Html.Partial("_ProductVariantAddToCart", defaultProductVariant.AddToCart, dataDictPrice)                    
                        }

                        @Html.Action("ShareButton", "Catalog")

                    </div>
                    <div class="clear">
                    </div>
                    @if (errors.Count > 0)
                    {
                        //display errors  
                        <span class="message-error">
                            @for (int i = 0; i < errors.Count; i++)
                            {
                                @errors[i]
                                if (i != errors.Count - 1)
                                {
                                    <br />
                                }
                            }
                        </span>
                        <div class="clear">
                        </div>
                    }

                    @{
                        var dataDictAttributes = new ViewDataDictionary();
                        dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", defaultProductVariant.Id);
                        @Html.Partial("_ProductAttributes", defaultProductVariant.ProductVariantAttributes, dataDictAttributes)                  
                    }
                    <div class="clear">
                    </div>
                    @{
                        var dataDictGiftCard = new ViewDataDictionary();
                    dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", defaultProductVariant.Id);
                        @Html.Partial("_GiftCardInfo", defaultProductVariant.GiftCard, dataDictGiftCard)
                    }

                </div>

                @if (shopAllThemeSettings == null || !shopAllThemeSettings.ShopAllThemePluginsSettings.IntegrateNopQuickTabs)
                {
                    <div class="fulldescription">
                        @Html.Raw(Model.FullDescription)
                    </div>
                }
            </div>
        </div>
        <div class="clear">
        </div>
        if (shopAllThemeSettings == null || shopAllThemeSettings.ShopAllThemePluginsSettings.IntegrateNopQuickTabs)
        {
            @Html.Action("ProductTabs", "ProductTab")
        }
        else
        {
            <div class="product-collateral">
                <div class="product-variant-line">
                    <!--product tier prices-->
                    @Html.Action("ProductTierPrices", "Catalog", new { productVariantId = defaultProductVariant.Id })
                </div>
                <div>
                    @Html.Action("ProductSpecifications", "Catalog", new { productId = Model.Id })
                </div>
                <div class="clear">
                </div>
                <div>
                    @Html.Action("ProductTags", "Catalog", new { productId = Model.Id })
                </div>
                <div class="clear">
                </div>
                <div>
                    @Html.Action("ProductsAlsoPurchased", "Catalog", new { productId = Model.Id })
                </div>
                <div class="clear">
                </div>
                <div>
                    @Html.Action("RelatedProducts", "Catalog", new { productId = Model.Id })
                </div>
            </div>
        }
    }
</div>
12 anni tempo fa
Hmmm... the file looks OK. I presume that you (or theme author) made some breaking changes in the source code or views. It's hard to say where the issue is without debugging.
12 anni tempo fa
Interesting thing is sample cards work fine. If I copy a card it breahs regardless of grid or single product
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.