an ASP.NET Open Source CMS & eCommerce platform
Search:
Last Post 1/25/2011 11:50:05 AM By rmi-andrew. 8 replies.
12/7/2010 12:20:32 PM
RMI-Jon
Posts: 24
Joined: 3/4/2009
Location:Ohio
price range
Hi Luke,
    We would like to see a feature that would let us show a price range on the category and product pages instead of the static price when using variable pricing in product attributes.
12/7/2010 12:37:51 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: price range
You can add a custom field say "Price Range" to Product. Take a look at this for how to add the custom field. And then you can use Product.CustomFields in the appropriate places e.g. Web\Store\ProductSummary\Price.ascx.cs.
DotShoppingCart Staff
1/21/2011 12:02:03 PM
rmi-andrew
Posts: 6
Joined: 1/21/2011
Location:OH
Re: price range
We've created the custom field "PriceRange" and added to Web\Store\ProductSummary\Price.ascx.cs. Snipet of code below:
 
Our thinking is that if there is no data in the PriceRange field, then continue processing the pricing procedure normally.  If there is data in the PriceRange field, then display that instead of the normal pricing
 
-*-*-*-*-*-*-*
 
    public override void DataBind() {
        base.DataBind();
        if (null != Product.PriceRange) {
            lblCurrentPrice.Text = Product.PriceRange.ToString("c");
        } else { if (0 == Product.Price)
            lblCurrentPrice.Visible = lblCrossPrice.Visible = false;
 
-*-*-*-*-*-*-*
 
But gives the following error when the page loads
 
<span>

Server Error in '/shop' Application.<hr color="#c0c0c0" size="1" width="100%" />

Compilation Error

</span>Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'DotShoppingCart.Commercial.Core.Product' does not contain a definition for 'PriceRange' and no extension method 'PriceRange' accepting a first argument of type 'DotShoppingCart.Commercial.Core.Product' could be found (are you missing a using directive or an assembly reference?)

Source Error:

<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td> </td> </tr> <tr> <td>
Line 26:     public override void DataBind() {
Line 27:         base.DataBind();
Line 28:         if (null != Product.PriceRange) {
Line 29:             lblCurrentPrice.Text = Product.PriceRange.ToString("c");
Line 30:         } else { if (0 == Product.Price)
</td> </tr> </tbody> </table>
Source File: e:\docs\www.rettigmusic.com\DotShoppingCartSuiteV4.0.3\Web\Store\ProductSummary\Price.ascx.cs    Line: 28


<div class="expandable" onclick="OnToggleTOCLevel1('compilerOutputDiv')">Show Detailed Compiler Output:
<div id="compilerOutputDiv" style="display: none">
<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td>


Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

e:\docs\www.rettigmusic.com\DotShoppingCartSuiteV4.0.3\Web\Store\ProductSummary\Price.ascx.cs(28,29): error CS1061: '
DotShoppingCart.Commercial.Core.Product' does not contain a definition for 'PriceRange' and no extension method 'PriceRange' 
accepting a first argument of type 'DotShoppingCart.Commercial.Core.Product' could be found (are you missing a using directive or 
an assembly reference?)
e:\docs\www.rettigmusic.com\DotShoppingCartSuiteV4.0.3\Web\Store\ProductSummary\Price.ascx.cs(29,44): error CS1061: 
'DotShoppingCart.Commercial.Core.Product' does not contain a definition for 'PriceRange' and no extension method 'PriceRange' 
accepting a first argument of type 'DotShoppingCart.Commercial.Core.Product' could be found (are you missing a using directive 
or an assembly reference?)
</td> </tr> </tbody> </table>

<div class="expandable" onclick="OnToggleTOCLevel1('dynamicCodeDiv')">Show Complete Compilation Source:
 
<div id="dynamicCodeDiv" style="display: none">
<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td>
Line 1:    #pragma checksum "E:\docs\www.rettigmusic.com\DotShoppingCartSuiteV4.0.3\Web\Store\ProductSummary\Price.ascx" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "C8AFEE0E6A5EC7966A70330978FFCC53"
</td> </tr> </tbody> </table> 
 
 
<script type="text/javascript"> function OnToggleTOCLevel1(level2ID) { var elemLevel2 = document.getElementById(level2ID); if (elemLevel2.style.display == 'none') { elemLevel2.style.display = ''; } else { elemLevel2.style.display = 'none'; } } </script>

<hr color="#c0c0c0" size="1" width="100%" />
Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618
 
What else am I missing?
 
 
1/25/2011 9:32:55 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: price range
You need to use Product.CustomFields to get access to the custom field that you added.
DotShoppingCart Staff
1/25/2011 9:52:03 AM
rmi-andrew
Posts: 6
Joined: 1/21/2011
Location:OH
Re: price range
So here's what I tried next
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        base.DataBind();
        if (null != Product.CustomFields.PriceRange) {
            lblCurrentPrice.Text = Product.CustomFields.PriceRange.ToString("c");
        } else { if (0 == Product.Price)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 
And it errored as follows
 

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'System.Collections.Generic.List<DotShoppingCart.Commercial.Core.CustomField>' does not contain a definition for 'PriceRange' and no extension method 'PriceRange' accepting a first argument of type 'System.Collections.Generic.List<DotShoppingCart.Commercial.Core.CustomField>' could be found (are you missing a using directive or an assembly reference?)

Source Error:

<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td> </td> </tr> <tr> <td>
Line 26:     public override void DataBind() {
Line 27:         base.DataBind();
Line 28:         if (null != Product.CustomFields.PriceRange) {
Line 29:             lblCurrentPrice.Text = Product.CustomFields.PriceRange.ToString("c");
Line 30:         } else { if (0 == Product.Price)
</td> </tr> </tbody> </table>
Source File: e:\docs\www.rettigmusic.com\DotShoppingCartSuiteV4.0.3\Web\Store\ProductSummary\Price.ascx.cs    Line: 28

1/25/2011 10:04:07 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: price range
CustomFields is a List of CustomField. Try
        var priceRange = Product.CustomFields.SingleOrDefault(c => c.Name == "PriceRange");
        if (priceRange != null)
            // then use priceRange.Value
DotShoppingCart Staff
1/25/2011 10:27:32 AM
rmi-andrew
Posts: 6
Joined: 1/21/2011
Location:OH
Re: price range
DotShopping still isn't happy
 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    public override void DataBind() {
        base.DataBind();
        var priceRange = Product.CustomFields.SingleOrDefault(c => c.Name == "PriceRange");
        if (priceRange != null) {
            lblCurrentPrice.Text = priceRange.Value;
        } else { if (0 == Product.Price)
 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'System.Collections.Generic.List<DotShoppingCart.Commercial.Core.CustomField>' does not contain a definition for 'SingleOrDefault' and no extension method 'SingleOrDefault' accepting a first argument of type 'System.Collections.Generic.List<DotShoppingCart.Commercial.Core.CustomField>' could be found (are you missing a using directive or an assembly reference?)

Source Error:

<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td> </td> </tr> <tr> <td>
Line 26:     public override void DataBind() {
Line 27:         base.DataBind();
Line 28:         var priceRange = Product.CustomFields.SingleOrDefault(c => c.Name == "PriceRange");
Line 29:         if (priceRange != null) {
Line 30:             lblCurrentPrice.Text = priceRange.Value;
</td> </tr> </tbody> </table>
Source File: e:\docs\www.rettigmusic.com\DotShoppingCartSuiteV4.0.3\Web\Store\ProductSummary\Price.ascx.cs    Line: 28

1/25/2011 10:32:04 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: price range
Did you have the following at the top? If not, add it.
using System.Linq;
DotShoppingCart Staff
1/25/2011 11:50:05 AM
rmi-andrew
Posts: 6
Joined: 1/21/2011
Location:OH
Re: price range
That worked - thank you very much!