0

I would like to add some products to my cart while I am on checkout process. The cart appears to be empty at the time. I want to make a selection of some add-on products on the checkout process.

I created my own custom checkout pane(it's a form). Also a submit function.

There are "commerce_line_items" in the order object, but then I get an error that says my entity is missing bundle. There is also 'commerce_order_total' that includes the totals? so I can't just edit the object/array?

This is how I create my line item:

$line_item = commerce_product_line_item_new($product, 1, $order->order_id);

This is how I am trying to add it to my order:

$order->commerce_line_items['und'][] = array('line_item_id' => $line_item->line_item_id);
1
  • You should never hard-code 'und' into your code like that. Please use the Drupal constant LANGUAGE_NONE instead! May 22, 2012 at 15:52

1 Answer 1

0

You likely need to save the line item before adding it to the order. The order total should be recomputed for you automatically on save.

1
  • Thank you, I thought of it before. Don't know why I didn't try to do this, cause nodes in Drupal behave like this. The function is really obvious: commerce_line_item_save($line_item);
    – ram4nd
    May 23, 2012 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.