Vote up!
Vote down!

Basic Drupal Commerce functions not being seen

I am getting the following error when invoking "commerce_cart_order_product_line_item_delete()" in a custom module i'm writing.

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

The "commerce_entity_reference_delete()" function that Drupal claims it can't find resides in:


...which, if I understand correctly is THE main commerce module that makes the whole shopping cart functionality work. So... my commerce module is enabled (because my shopping cart is working, and which is confirmed also on the Modules page), so why isn't commerce.module serving up the function above for me?

Am I not allowed to call "commerce_cart_order_product_line_item_delete()" from a custom module?

Desperately looking for a solution... thanks!

Asked by: Reuben Lara
on February 16, 2014

1 Answer

Vote up!
Vote down!


I can call commerce_cart_order_product_line_item_delete() and commerce_entity_reference_delete()
from a module without any problems.

function my_sandbox_form_alter(&$form, &$form_state, $form_id) {

-- gives me lots of argument & variable errors, but so it should...


  1. Maybe you have a typo?
  2. Missing a module?
  3. Clear the cache.
  4. Have you moved the location of the modules from/to sites/all?
Andy @ BlueFusion
Posted: Feb 16, 2014


Thanks so much for answering. I double checked and no typo; Module is there; Cleared the cache; haven't moved the commerce module from the default install location. However, now that you mention it, the default install location is not sites/all. The install threw it in the profiles/commerce_kickstart/modules location. Should they be in the sites/all folder? Also, I am not calling commerce_cart_order_product_line_item_delete(); from within another function like in your example above, but just straight out between other php code. Is that wrong?

- Reuben Lara on February 16, 2014

Hi, I only just got notification that you'd replied so sorry for the delay. It's probably worth creating a quick demo module like the above and making sure that it runs in that. If it does then you know that the module isn't available from wherever you're calling it.
Whether you're calling it 'wrong' or not depends on the code you're calling it from. If you're not calling it in a module or a function, where/what are you calling it from?

If the module is in the profile then leave it there, I think you're right that it is part of the distribution - that's probably not the problem.

- Andy @ BlueFusion on March 5, 2014