Adding Database Field to Control

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
User avatar
napacabs
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 45
Joined: Mon Jan 14, 2008 2:58 pm
Location: Chino, California
Contact:

Adding Database Field to Control

Post by napacabs » Wed Jan 18, 2012 6:18 pm

How would you add the field "EndDate" from the Specials (product pricing rules) table to the FeaturedProductsGrid control in a 01/01/2012 format? Thank You.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Adding Database Field to Control

Post by jmestep » Thu Jan 19, 2012 8:48 am

To get that price, you would need to add that to the ConLib/ProductPrice. Use pcalc to get the price (that contains all the correct logic, like if it applies to the customer's user group)
The special price displays in the price popup in that file, so you would need either add code there to show the special price on the normal display for the page where it is used or add it separately to the file where the ProductPrice is used.
SpecialPrice.Text = string.Format(PopupSpecialPriceFormat, priceWithVAT, pcalc.AppliedSpecial.EndDate);
The special price format is defined at the top of the file
private string _PopupSpecialPriceLabel = "<b>Sale Price:</b>";
private string _PopupSpecialPriceFormat = "{0:ulc} ends {1:d}";
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
napacabs
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 45
Joined: Mon Jan 14, 2008 2:58 pm
Location: Chino, California
Contact:

Re: Adding Database Field to Control

Post by napacabs » Thu Jan 19, 2012 11:15 am

Hi Judy,

Tried that but what I need is to only isolate the EndDate, to be used as a variable in a Javascript. I would like to create a timer which counts down to the end of sale, the script works properly on the product detail page content scriptlet as follows:

<script language="JavaScript">
StartCountDown("clock1","#foreach($pcf in $Product.Specials)#if($pcf.ProductID == $Product.ProductId)$pcf.EndDate.ToString("MMM dd, yyyy")#end#end 11:59:59 PM -0700")
function StartCountDown(myDiv,myTargetDate)...

However, within a control such as "Featured Products" using a modified price user control "<%@ Register Src="~/ConLib/Utility/ProductPrice_MOD.ascx" TagName="ProductPrice" TagPrefix="uc" %>" with code behind "private string _SpecialPriceFormat = "{1:d}";"
the variable EndDate is hidden as follows:

Viewed from page source:
<script language="JavaScript">
StartCountDown("clock11699","<input type="hidden" name="ctl00$wpm$...$Price2$VS" id="ctl00...VS" value="sB6J...hD" /> 11:59:59 PM -0700")
function StartCountDown(myDiv,myTargetDate)...

The ProductId used in the ID "clock11699" was properly inserted with "clock<%# ProdID(Container.DataItem)%>". How can I get ac_Specials EndDate (from "EditProduct > Pricing Rules") to be used as <%# EndDate(Container.DataItem)%> or what is the code to be able to assign a value to the hidden variable field?

Thanks

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Adding Database Field to Control

Post by jmestep » Fri Jan 20, 2012 9:17 am

In your code behind you would do something like
protected DateTime GetEndDate(object dataItem)
{

Product product = (Product)dataItem;
DateTime endDate = LocalHelper.LocalNow; //whatever date time you want to start with
//do the pcalc stuff here like what is in the Utility/ProductPrice
//check the date against the endDate above
return endDate

}
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply