Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // For debugging, this function is called by hook_menu()
- function mymodule_test($product_id)
- {
- global $user;
- $user = user_load($user->uid);
- $order = commerce_cart_order_load($user->uid);
- $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
- $product = commerce_product_load($product_id);
- $line_item = commerce_product_line_item_new(
- $product,
- 1,
- 0,
- array(
- ),
- 'cover'
- );
- $line_item_wrapper = entity_metadata_wrapper("commerce_line_item", $line_item);
- $line_item_wrapper->commerce_unit_price->data = commerce_price_component_add(
- $line_item_wrapper->commerce_unit_price->value(),
- 'base_price',
- array(
- 'amount' => 1234,
- 'currency_code' => 'EUR',
- 'data' => array(),
- ),
- TRUE
- );
- $insert_line_item = commerce_cart_product_add($user->uid, $line_item_wrapper->value(), FALSE);
- return 'done';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement