[ic] Multiple Sizes/Prices and Inventory ... an answer (I hope)and more questions ...

Mike Heins interchange-users@icdevgroup.org
Sat Jul 6 11:58:00 2002


Quoting Jon (prtyof5@attglobal.net):
> This was late last night I was playing with this. I just looked at it
> some more and I see if you use the matrix option is establishes
> multiple products for the inventory but doesn't seem to link those new
> option products back to the base product total. That could be because
> I messed up the options table. So it seems as if I use the simple
> option I can utilize widget=checkbox but then those are a single
> products in the inventory table, or I use matrix, creating multiple
> products for inventory but not with a checkbox.. I now believe it is
> there but I haven't quite figured it all out.....
> 

This is correct. You can't maintain inventory for options without
maintaining a line in an inventory database, which implies a uniquely
generated key for that item.

Matrix options is definitely what you want. At that point, you should be
able to set inventory levels for each of the variants.  I believe the
decrement stuff in etc/log_transaction will use the variant code in
[item-code] instead of the base item in [item-sku].

You might have to change your inventory-showing code in the display
pages. I did something like this for an apparel site:

[query sql="
		SELECT code,description
		FROM   options
		WHERE  sku = '[item-code]'
		AND    price > 0
	    "
	list=1
]
    [if
        type=data
        term="inventory::quantity::[sql-code]"
        op=">"
        compare=0
    ]
	<B>[sql-param description]</B>
	[page href="order"
	      form="
		    mv_order_item=[item-code]
		    mv_sku=[sql-code]
		"]<img src="buynow.gif" border=0 alt="Add To Cart"></a><br>
    [/if]
[/query]

That will check inventory on a variant and only offer it for order if
the quantity is greater than zero.

That can be further simplified to remove the [if ...] with the proper
sql query, off the top of my head:

        SELECT options.code,options.description
        FROM   options, inventory
        WHERE  options.sku = '[item-code]'
        AND    inventory.sku = options.code
        AND    options.price > 0

Which has the same effect as:

[loop search="
		fi=options
		co=yes
		
		sf=sku
		se=[item-code]
		op=eq
		nu=0

		sf=price
		se=0
		op=>
		nu=1

		sf=inventory:quantity
		se=0
		op=>=
		nu=1

		rf=code,description
	    "
]
    <B>[loop-code] -- [loop-param description]</B>
    [page href="order"
          form="
                mv_order_item=[item-code]
                mv_sku=[loop-code]
	    "]<img src="buynow.gif" border=0 alt="Add To Cart"></a><br>
[/loop]

Bottom line, whatever you need do can be done. It is just a question of
understanding....isn't that always the question in life? 8-)

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

"Even if you're on the right track, you'll get run over if you just
sit there." -- Will Rogers