1 reply [Last post]
douglas.a.hatch's picture
Offline
Joined: 07/31/2009
Juice: 64
Was this information Helpful?

Is it possible to add a product kit using a cart link and specify the attributes and options for the underlying products comprising the kit? I've tried to find the correct syntax for this, but after looking at the Ubercart code, I don't think it's even possible. I can of course just add each of the products in the kit individually. But I need them to show up as a single unit in the cart and elsewhere (e.g. invoices). So using a product kit is logical. Any help is appreciated. Thanks!

douglas.a.hatch's picture
Offline
Joined: 07/31/2009
Juice: 64
Hacked the core...

Well, I hate to do it, but I had to hack the core to get this one working. Here's the snippet in case anyone is interested. Goes in uc_cart_links.pages.inc circa line 149.

     if (isset($node->products) && is_array($node->products)) {
          foreach ($node->products as $nid => $product) {
       $temp_array = array_intersect_key($p['attributes'],$product->attributes);
       $p['data']['products'][$nid] = array(
     'nid' => $nid,
     'qty' => $product->qty,
     'attributes' => $temp_array,
);
  }//End For
  unset($p['attributes']);
     }//End If

Basically, this allows you to create a cart link with the product kit nid and a trailing list of attributes and options (which belong to the underlying products). Here is an example:

/cart/add/p212_q1_a26o1_a25o2_a22o3_a6o111_a47o136_a23o4_a29o71_a54o5_a30o67_a55o7_a24o8_a14o42

If the cart links module detects that this is a product kit (i.e. p212), it breaks out the underlying products (default) and then goes through and assigns the attributes to their respective products (my hack).

If anyone has a more elegant solution, I'm all ears. Thanks!