[ic] stacked variants problem

Schuyler Langdon interchange-users@icdevgroup.org
Sat Nov 9 21:24:00 2002


Jeff Dafoe wrote:


> Hello,
>
> I am experiencing an inability to add stacked variants to the cart
properly.
>
> I have a base product  "base" and variants "variant1" and "variant2"
>
> This works:
>
> <input type=hidden name="mv_order_item" value="base">
> <input type=hidden name="mv_sku" value="variant1">
> <input type=hidden name="mv_order_quantity" value=1>
>
> and ends up with
>
>       'carts' => {
>                        'wishlist' => [],
>                        'main' => [
>                                    {
>                                      'price_group' => '',
>                                      'mv_sku' => 'base',
>                                      'mv_ib' => 'options',
>                                      'code' => 'variant1',
>                                      'quantity' => '1'
>                                    }
>                                  ]
>                      }
>
> Unfortunately, stacking that does not work:
>
> <input type=hidden name="mv_order_item" value="base">
> <input type=hidden name="mv_sku" value="variant1">
> <input type=hidden name="mv_order_quantity" value=0>
> <input type=hidden name="mv_order_item" value="base">
> <input type=hidden name="mv_sku" value="variant2">
> <input type=hidden name="mv_order_quantity" value=1>
>
> An examination of the cart reveals that the variant has been lost.
>
>          'carts' => {
>                        'wishlist' => [],
>                        'main' => [
>                                    {
>                                      'price_group' => '',
>                                      'mv_sku' => '00081',
>                                      'mv_ib' => 'products',
>                                      'code' => '00081',
>                                      'quantity' => '1'
>                                    }
>                                  ]
>                      },
>
> By removing mv_order_item and leaving only mv_sku and mv_order_quantity I
> can produce
> Attempt to order missing product code: 100177-100180-100178-100179
> in the error log.
>
> By removing mv_sku and setting mv_order_item to "variant1" I can produce:
>
>           'carts' => {
>                        'wishlist' => [],
>                        'main' => [
>                                    {
>                                      'price_group' => '',
>                                      'mv_ib' => 'options',
>                                      'code' => 'variant1',
>                                      'quantity' => '1'
>                                    }
>                                  ]
>                      },
>
> which gives me the closest approximation to functionality, however, the
> absence of mv_sku in the cart seems to cause issues in item-list,
primarily
> I cannot reference the base item in an item-list with a tag such as
> [item-data products description].  This makes me think that there might be
> other issues introduced also.
>
> Any insight is very appreciated.
>

I was trying to set up a similar thing recently (version 4.8). Looking at
Order.pm, it is not set up to handle stacking products with matrix options.
The mv_sku fields are parsed and applied to the first product (index 0).
This makes sense because it has to handle a varying number of "mv_skus" for
each item. So, I did the next best thing and only included an option
selection for the first item and not for the additional stacked items (which
also have matrix options). However when you do this, the mv_sku options are
applied to all items being added. It looks like a problem in Order.pm with
the following line:
$item->{mv_sku} = $skus[$i] if defined $skus[$i];
which probably should be:
$item->{mv_sku} = $skus[$j] if defined $skus[$j];
I posted this and an explaination a couple weeks ago.
When this modification is made all items will be added to the cart properly,
and the matrix options will be selectable as usual for the secondary items
once the items have been "placed in the cart".

If you would prefer to have the matrix options selectable for the secondary
items from the order page (usually flypage in the foundation), Order.pm
would have to be modified to additionally parse a mv_sku field based upon
index (like it's handled once items are placed in the cart). ie mv_sku0
would be an array of options for the first item, mv_sku1 for the second,
etc. These options would then be added to @skus and applied to the item as
mentioned above. This method would involve a core modification, albiet a
rather simple one.

--
Schuyler Langdon
GatorDev