0

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:

/[site]/profiles/commerce_kickstart/modules/contrib/commerce/commerce.module

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?

Why am I not allowed to call commerce_cart_order_product_line_item_delete() from a custom module?

Bleeding Fingers
  • 6,993
  • 7
  • 46
  • 74
sakeferret
  • 305
  • 1
  • 6
  • 15
  • Have you declared the commerce module as a dependency in your module? You could also try to include it in your module explicitly using [module_load_include](https://api.drupal.org/api/drupal/includes!module.inc/function/module_load_include/7) – CBroe Feb 16 '14 at 15:31
  • @CBroe Thank you that was super helpful. Declaring as dependencies did not work, but including it through module_load_include did the trick to get them seen. I had to include both "commerce" and "views" within my custom module. Now, however, I get the following error: Exception: theme() may not be called until all modules are loaded. in theme() (line 1005 of /Users/[user]/Documents/Sites/[site]/includes/theme.inc). How can I get theme modules declared and included before "theme()" is called? – sakeferret Feb 17 '14 at 03:43

0 Answers0