I am adding an item using the following code:
$some_data = array(
'attributes' => array(
6 => $domainName,
1 => $domain->oid,
2 => 705,
7 => 706,
8 => '',
9 => '',
10 => '',
11 => '',
),
);
$some_data = serialize($some_data);
uc_cart_add_item(
$domainProductNID,
1,
$some_data
);
It adds the item to the cart, with the correct configuration. However, if I then go to /cart and click on "remove", the item stays there. I am only able to remove it with:
uc_cart_empty();
Any idea why?
UPDATE
Removing the $some_data attribute and instead running:
uc_cart_add_item(
$domainProductNID,
1
);
Does in fact work... so it must have something to do with the attributes being submitted.
This solved my problem:
$domainProductNID = 27;
$form_state = array(
'values' => array(
'nid' => $domainProductNID,
'qty' => 1,
'attributes' => array(
6 => $domainName,
1 => $domain->oid,
2 => 705,
7 => 706,
8 => '',
9 => '',
10 => '',
11 => '',
)
),
);
$node = node_load($domainProductNID);
drupal_form_submit("uc_product_add_to_cart_form", $form_state, $node);
Hope it helps someone else...