News:

Support the VirtueMart project and become a member

Main Menu

SKU Session Variable

Started by Hadesmod, October 04, 2013, 07:01:01 AM

Previous topic - Next topic

Hadesmod

Hello There,

I'm a pretty novice programmer, but here is what I am trying to do, and what I've done so far:

What I want:

I'm trying to get a final SKU in the cart, made up of the product's variant selections.

For example, if the initial product is "Shovel" as shown on my test site, and it's SKU is "SHO", the variants selection SKU number adds to the end.

If one of the variants were:

Handle Color
-- Green Handle (with SKU of SKU1)
-- Yellow Handle (with SKU of SKU2)

The final SKU would be SHO - SKU1  if green were chosen, and SHO - SKU2 if yellow was chosen)

This would then create a session variable to pass onto the cart, and the cart would display this variable and I'd be able to pass it to an email notification, or anything I need after.

What I've done:

I've added a column custom_sku to the cart variant data in the table virtuemart_product_customfields. I've also added this field to the customs.php file in the administrator tables folder (/administrator/components/com_virtuemart/tables)

This field now updates into the database and each time you add a cart variant option, it adds an SKU to the column "custom_sku" for the row of the customfield_id:

Screenshot: http://awesomescreenshot.com/02e1sfsef9

I've also modified the function getProductCustomsFieldCart in customfields.php (administrator/components/com_virtuemart/models) to add this into the option drop down value.

Now a value looks like: "Variant Value - $1.00 - SKU1"

What I'm stuck on:
I need to pass this SKU value, or the value of the option over to the cart, and have it so I can use this for remaining parts of the order.

This should most likely be done with a session variable, which looks like:    sessionSKUselect = "20"   where 20 is the custom field ID so I can use this in a query on the cart.

This can also be output in a session variable in an array, as long as it works.

There is currently a variable passed through the form that looks like: "customPrice[0][1]"  (the numbers pertain to which select list, and its variant group (which select list))

Does anyone have any ideas?