1

I've set up my own custom module structure, and am trying to implement commerce_cart_order_product_line_item_delete. At it's most basic level, i'm trying to delete line item 70 from order 1 in my cart with the following code in my module:

<?php
    commerce_cart_order_product_line_item_delete(1,70,FALSE);
?>

I'm getting this error on the page:

Fatal error: Call to undefined function commerce_entity_reference_delete() in /Users/[username]/Documents/Sites/[site_name]/profiles/commerce_kickstart/modules/contrib/commerce/modules/cart/commerce_cart.module on line 1268

I've tried other methods, like the code on this page:

http://dropbucket.org/node/358

but i can't seem figure out how to find a product's ID, and in the end, I want to delete a line item from a cart which could potentially have two entries of the same product. don't want to delete the whole product from the cart... hope that makes sense.

What am I missing? thanks!

0

The function accepts the $commerce_order object not just the order_id. You could try

commerce_cart_order_product_line_item_delete($order, 70);

commerce_entity_reference_delete is defined in commerce.module so it should be available, if commerce is enabled and at current version.

3
  • thanks. tried that and got the same error. I'm using Drupal Commerce so I assume that all necessary functions are being fired... i've dug into commerce.module, and sure enough, the function is there. Any reason why my build is not seeing it?
    – sakeferret
    Feb 14 '14 at 1:56
  • Verify the commerce module is enabled, and therefore included in the request - presumably it must be. Feb 14 '14 at 1:57
  • checked, and definitely is. commerce.module is THE core component of the whole setup. not sure why that function is not being found?
    – sakeferret
    Feb 14 '14 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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