Microsoft .NET Server Solutions for the Enterprise

RemoteBasket.asp from Basket.asp

When the new page RemoteBasket.asp was created from a copy of the page basket.asp, a number of changes where made to the routine htmRenderBasket. This section examines those changes by presenting an annotated version of the modified code in the page RemoteBasket.asp.

When reading through this code, note the following conventions:

The new version of the routine htmRenderBasket that is used in the page RemoteBasket.asp is functionally very similar to the original version in the page basket.asp. The only difference is that the new version does not support discount processing. The annotated, abbreviated version of the routine htmRenderBasket follows:

Function htmRenderBasket(mscsOrderGrp, oOrderFormDisplayOrder) Dim sOrderFormName, mscsOrderForm, dictItem, listAggregatedItems, ... Dim i, urlLink, urlAction, bDiscountApplied, sProdCode, htmLinkText Dim htmBasketHeaderRow, htmBasketDataRow, htmQtyCol, htmProdCode, ... Dim arrData, arrParams, arrParamVals, arrDataAttLists

The following bold code, added to the page RemoteBasket.asp, defines two new variables for calculating the item totals and the basket total without using any discount processing. It also initializes the basket total variable to zero in preparation for tallying.

Dim fItemTotalWithNoDiscount, fBasketTotalWithNoDiscount ' NOTE: Discounts are not applicable to Remote shopping baskets - ' Code rendering discount info below is commented ' and kept commented for future use... fBasketTotalWithNoDiscount = 0 bDiscountApplied = False Set listAggregatedItems = Server.CreateObject("Commerce.SimpleList") For Each sOrderFormName in oOrderFormDisplayOrder Set mscsOrderForm = mscsOrderGrp.Value(ORDERFORMS).Value(sOrderFormName)

The following bold code, commented out in the page RemoteBasket.asp, prevents discounts from ever being applied to the contents of a remote shopping basket.

'If mscsOrderForm.Value("_winners").Count > 0 Then 'bDiscountApplied = True 'End If For Each dictItem In mscsOrderForm.Items Call listAggregatedItems.Add(dictItem) Next Next

.

. Code that was not changed has been removed here.

.

arrParams = Array(CATALOG_NAME_URL_KEY, CATEGORY_NAME_URL_KEY, ... arrParamVals = Array(dictItem.Value("product_catalog"), ... urlLink = GenerateURL(MSCSSitePages.DeleteItem, arrParams, arrParamVals) htmLinkText = RenderText(mscsMessageManager.GetMessage( ... htmRemoveCol = RenderLink(urlLink, htmLinkText, MSCSSiteStyle.Link)

The following bold code, added to the page RemoteBasket.asp, does a simple calculation to determine the total item price (quantity times price), and adds to the running total price for the entire remote shopping basket.

' Discounts are not applicable to Remote shopping baskets - only show ' product's adjusted list price and its actual extended total. fItemTotalWithNoDiscount = dictItem.quantity * _ dictItem.Value("_cy_iadjust_currentprice") fBasketTotalWithNoDiscount = fBasketTotalWithNoDiscount + fItemTotalWithNoDiscount If bDiscountApplied Then

.

. Code that was not changed has been removed here.

.

Else ' "name" and "description" are required product properties ' and cannot have null values. arrData = Array(_ htmQtyCol, _ htmProdCode, _ dictItem.Value("_product_name"), _ dictItem.Value("_product_description"), _ htmRenderCurrency(dictItem.Value("_cy_iadjust_currentprice")), _

The following bold code, modified in the page RemoteBasket.asp, adds a formatted version of the item total to the array that specifies the values for the current row in the basket page table. In the page basket.asp, this line is:

htmRenderCurrency(dictItem.Value("_cy_oadjust_adjustedprice")), _ htmRenderCurrency(fItemTotalWithNoDiscount), _ htmRemoveCol) End If htmRenderBasket = htmRenderBasket & RenderTableDataRow(arrData, arrDataAttLists, _ MSCSSiteStyle.TRMiddle) Next urlLink = GenerateURL(MSCSSitePages.DeleteAllItems, Array(), Array()) htmLinkText = RenderText( _ mscsMessageManager.GetMessage("L_RemoveAll_HTMLText", sLanguage), _ MSCSSiteStyle.Body _ ) arrData = Array( _ NBSP, _ mscsMessageManager.GetMessage("L_BASKET_SUBTOTAL_COLUMN_TEXT", ...

The following bold code, modified in the page RemoteBasket.asp, adds a formatted version of the basket total to the array that specifies the values for the final, sparse row in the basket page table. In the page basket.asp, this line is:

htmRenderCurrency(mscsOrderGrp.value.saved_cy_oadjust_subtotal), _ htmRenderCurrency(fBasketTotalWithNoDiscount), _ RenderLink(urlLink, htmLinkText, MSCSSiteStyle.Link))

.

. Code that was not changed has been removed here.

.

htmRenderBasket = RenderForm(urlAction, htmRenderBasket, HTTP_POST) End Function

Previous  Next

Категории