GRD_CART Grid Component
Purpose
The GRD_CART grid component displays the contents of the customer's shopping cart. It allows the customer to change item quantities or remove items from the cart.
Description
The GRD_CART component is an updateable grid which displays a view with fields from the shop_cart, product, and specials tables. The view grid contains three calculated fields. Users may edit or delete, but not insert new records.
NPrice = if(Specials->Sale_Price > 0 .and. (cdate(Specials->Sale_Until) >= cdate(date()) .or. cdate(Specials->Sale_Until) = ""), Specials->Sale_Price, Product->Retail) ext = Quantity * if(Specials->Sale_Price > 0 .and. (cdate(Specials->Sale_Until) >= cdate(date()) .or. cdate(Specials->Sale_Until) = ""), Specials->Sale_Price, Product->Retail) Sale_Until = if(Specials->Sale_Price > 0, cdate(Specials->Sale_Until), "00000000") |
The grid's filter expression is quantity>0. The order expression lists items alphabetically by their descriptions.
Containers
Notable Grid Control Property Settings
Control |
Property |
Description |
Desc |
Display Settings > Control type |
"Link" |
Link Properties > Display what in link |
"Value in Field" | |
Link Properties > Link address type |
"Computed from fields in the grid" | |
Link Properties > Link address |
When clicked, displays the PRODUCTINFO.A5W page showing the product defined by prod_id. productinfo.a5w?pid={Prod_Id} | |
List |
Display Settings > Display format |
Only shows prices that are greater than zero. if(<value>=0, "", str(<value>,20,2,"$,")) |
Nprice |
Display Settings > Control type |
"Custom" |
Custom Control Properties > Definition |
||
Sale_Until |
Display Settings > Display format |
If the end of sale date is greater than the current date, it displays the label "Special!". if(<value>>=cdate(date()) .or. <value>="", "Special!","") |
Ext |
Display Settings > Display format |
Only shows prices that are greater than zero. if(<value>=0, "", str(<value>,20,2,"$,")) |
The beginning of the custom control script sets new_price to NULL, if its value is zero or negative. Otherwise, it formats it as a dollar value.
function NPrice_render as c (data as p, args as p, PageVars as p) with PageVars on error goto NPrice_xbasicError new_price = if(Data.NPrice > 0, alltrim(str(Data.NPrice, 20, 2, "$, ")), "") |
If the product is still on sale, the next two statements create the HTML (NPrice_render) that will show the price with a bold red font.
if Data.Sale_Until >= cdate(date()) NPrice_render = <<%html% <strong><font color=#ff0000>__price__</font></strong> %html% elseif Data.Sale_Until = "" NPrice_render = <<%html% <strong><font color=#ff0000>__price__</font></strong> %html% |
If the product is not on sale, the price is shown without highlighting.
else NPrice_render = <<%html% __price__ %html% end if |
Finally, the script substitutes the value of new_price for __price__.
NPrice_render = stritran(NPrice_render, "__price__", new_price) end NPrice_xbasicError: NPrice_render = "Error in custom control xbasic: " + error_text_get() end with end function 'do not delete this line |
See Also
Supported By
Alpha Five Version 7 and Above