[ic] How to determine the item option selections for the current cart...

Charles Adams interchange-users@icdevgroup.org
Thu Mar 27 16:31:01 2003


I am using IC 4.9.3 on a Red Hat 7.2 server with a site originally created
in 4.8.7 and upgraded to 4.9

I have a cart built using simple options and have edited the options weights
and prices to be "non-zero" for every option.

I need some advice on custom code to add option weights for just the options
selected on the check-out or basket pages (weights as specified in the
options table) to the summary weight for the shopping cart.

We're using simple options with weights values in the format
G=25.0,H=38.0,I=63.0,G2=50.0,H2=72.0, where "G" is the option value code
specified in the options table, much like the way prices are specified for
various options.

I assume I'll need to take an approach like the following

	For each item in the cart
		Determine which items are the "selected" options  		<HERE'S WHERE I NEED
THE HELP!>
			Lookup selected option weights
			Parse to determine weight for selected value
			Add weight for selected level * quantity to summary weight <Maybe here
too!>

I have some test code that looks up items available from the options table
for each item in the cart (code follows) but I do not know how to determine
only the item option currently selected for the current cart.  If anyone can
provide insight on the code to identify just the selected options in the
cart, then I can look up that options weight list, parse it and calculate
the adjusted weight.

The checkout pages looks like:
https://aboveboardmfg.com/~aboveboa/cgi-bin/cart.cgi/ord/checkout.html

Output from the test page code can be found at
http://aboveboardmfg.com/~aboveboa/cgi-bin/cart.cgi/ABM-OptionWeight.html,
but of course, you'd need items in your cart for it to display anything.
Don't worry, it's not a live store right now!

<!--  ***********  Code Sample ************* -->

<b>Begin Test Loop Code</b><br>
        [item-list modular=1]
<br>
<b>[item-sku]</b>&nbsp;[page [item-sku]]<b>[item-description]</b></a><br>
        [if-item-data options o_enable]
            [if-item-data !options o_modular]
<b>Begin Option Loop Code for sku [item-sku]</b><br>
[loop
             search="
                      st=db
                      fi=options
                      co=1
                      sf=sku
                      se=[item-field sku]
                      nu=0
                      to=n
                      rf=code,weight
                    "
        ]
Searched for option items for sku: [item-field sku] - Found the following
available...<br>
[list]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Code:>[loop-data options code]<
Weight:>[loop-data options weight]<br>
[/list]
[/loop]
<b>End Option Loop Code</b><br>

            [/if-item-data]
        [/if-item-data]<br>
            [if-item-field weight]
            [seti weight][summary amount=`[item-quantity] * [item-field
weight]`][/seti]
            [/if-item-field]
&nbsp;&nbsp;&nbsp;[item-sku] Quantity:&nbsp;[item-quantity]<br>
&nbsp;&nbsp;&nbsp;[item-sku] Subtotal:&nbsp;[item-subtotal]<br>
<b>End Test Loop Code</b><br><br>
        [/item-list]
</td>
</tr>
</table>

<!--  ***********  Code Sample ************* -->

Begin Test Loop Code

BM-7236 Benchmarx Workbench - 72in x 36in
Begin Option Loop Code for sku BM-7236
Searched for option items for sku: BM-7236 - Found the following
available...
      Option Code:>BM-7236-SColor<    Weight:><
      Option Code:>BM-7236-Drawer<
Weight:>G=25.0,H=38.0,I=63.0,G2=50.0,H2=72.0<
      Option Code:>BM-7236-FColor<    Weight:><
      Option Code:>BM-7236-LShelf<    Weight:>NY=100.0<
      Option Code:>BM-7236-WSHeight<    Weight:>WH34=4.0<
      Option Code:>BM-7236-SType<    Weight:><
      Option Code:>BM-7236-Lift<    Weight:>PM06=35.0, PM12=35.0, PE06=35.0,
PE12=35<
      Option Code:>BM-7236-Legs<    Weight:>ALY=8.0<
      Option Code:>BM-7236-Casters<    Weight:>MY=6.0<
      Option Code:>BM-7236-MArm<    Weight:>KY=15.0<
      Option Code:>BM-7236-OLight<    Weight:>OLY=25.0<
      Option Code:>BM-7236-AShelf<
Weight:>AS12=40.0,AS15=47.0,AS122=80.0,AS152=94.<
      Option Code:>BM-7236-BRail<    Weight:>EY=6.0, EY2=12.0<
      Option Code:>BM-7236-ULight<    Weight:>ULY=10.0<
      Option Code:>BM-7236-CSupport<    Weight:>JY=6.0<
      Option Code:>BM-7236-OStrip<    Weight:>FY=10.0,FY2=20.0<
      Option Code:>BM-7236-KPullout<    Weight:>LY=8.0<
End Option Loop Code

   BM-7236 Quantity: 3
   BM-7236 Subtotal: $3,651.00
End Test Loop Code




Chuck Adams
MotherboardZone
caadams@MotherboardZone.com
512-343-8891 Voice
888-581-0022 Fax

http://www.MotherboardZone.com