Make URL based on product price in ProductBox.cshtml

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 11 años
A while back you guys helped me with a similar problem:

https://www.nopcommerce.com/boards/t/18597/help-me-make-a-url-based-on-price.aspx

Now I want that same button to display on every page where the productbox is shown.

When I use that same code, of course I would get the following error:

Compiler Error Message: CS1061: 'Nop.Web.Models.Catalog.ProductOverviewModel' does not contain a definition for 'PriceValue' and no extension method 'PriceValue' accepting a first argument of type 'Nop.Web.Models.Catalog.ProductOverviewModel' could be found (are you missing a using directive or an assembly reference?)

So I realize oh look I could use Model.ProductPrice.Price instead of Price.Value. If I run it without the

  if ( @Model.ProductPrice.Price > 1000 )

part of the code, it works, but I only want that button to show for items over $1,000.

But when I add the $1000 minimum, I get the following error:

CS0019: Operator '>' cannot be applied to operands of type 'string' and 'int

Great. So this is where I get lost. What can I do to the code?

Here is what the code looks like right now:

    @{
        var leaseUrl = "https://lease.com/lease.cfm?";      
        if ( @Model.ProductPrice.Price > 1000 )
        {
            leaseUrl += "Cost=" + Model.ProductPrice.Price;

    <iframe name="Lease" id="Lease" style="height: 45px; width: 97px;" frameborder="0" src = "@leaseUrl"></iframe>  
    }
}

Thanks in Advance!
Hace 11 años

public partial class ProductPriceModel : BaseNopModel
{
    public string OldPrice { get; set; }

    public string Price {get;set;}

    public bool DisableBuyButton { get; set; }

    public bool AvailableForPreOrder { get; set; }

    public bool ForceRedirectionAfterAddingToCart { get; set; }
}


The Price property is a string. You need to cast it to an int before comparing for > 1000. :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.