Laddawn.com : Programming Spec-Calculate Cart Value

This new RPC program will calculate and return the Cart Total to the UI for display on all of the checkout screens.

Create new BP FCT.CART.MODVALUE:

  1. Loop through SHOPPINGCART.USR<6> looking for all lines with a quote number
  2. Read the quote total$ from QUDET<14> of first open line ***make sure you don't use QUHDR< 36> because this has discount removed already
  3. Sum up all quote total$ and return MOD.ITEM.TOTAL (see FCT.CART.STOCKVALUE as guide)
  4. Add FCT.CART.MODVALUE to BP.INCLUDES LAD.CALCULATED.FUNCTIONS

Create new LDLIB RPC$UTILITY_GETSESSIONINFO:

Create an new routine called RPC$UTILITY_GETSESSIONINFO to be used to get information needed by the UI about a session.  This utility will be called by the UI when the user first logs in.  For now the only thing we will be send along to the UI is the web discount%.  At some point, more logic will be added to this program.  If this is a c/e rep, the web discount is not given so the percent will be set to 0.  If this is a customer, the web discount will be given.  Once this program sets the web discount, the UI side may change this discount in the situation where c/e has to enter the order for a customer for some reason, and they give them the discount% as if the customer entered the order.  The percent will be carrier around in new named param WEB.DISCPCT for use by the database.

  1. Create new named param WEB.DISCPCT
  2.  If PORT.MARKER # "" then web discount% = 0 (this is c/e)
  3. If PORT.MARKER = '' then read the disc% from SYSCON WEB.DISC.LAD<1>.  Make sure to strip off the comments
  4. Send back the web discount% in RETURN.VALUE.  The UI will then carry around WEB.DISCPCT for use by other programs.

Create new LDLIB RPC$SHOPPINGCART_GETORDERVALUE:

  1. Get the value of Stock items by calling the existing function:  FCT.CART.STOCKVALUE()
  2. Calculate the value of MOD items by calling the new function: FCT.CART.MODVALUE()
  3. Using the named param WEB.DISCPCT, calculate the Web Discount$ as: (Stock Value + MOD Value) * Web Disc%
  4. Get the total value of all upcharges by calling the new function: WEB.CALC.UPCHARGES (no detail is needed for the cart total, just take the Upcharge Total)
  5. Note: we will not calculate Tax$ or Freight$ - current site doesn't include these in the cart total
  6. Return to UI in RETURN.VALUE:  Stock Value, MOD Value, Web Discount $, Upcharge Total$

The UI Side:

  1. Execute LDLIB RPC$SHOPPINGCART_GETORDERVALUE
  2. Product Total:  Stock Total + MOD Total
  3. Charges Total: Total Upcharge$
  4. Web Discount$: Web Discount$ * (-1)  *** Display as negative
  5. Cart Total:  (Product Total + Charges Total) - Web Discount