I need to add fields to the Ubercart entity uc_order_product. I was looking into the function field_create_instance, but don`t know exactly where to use it. I believe I should attach the field I want to the uc_order_product entity using field_create_instance.
The 'uc_order_product' definition in uc_order.module doesn't have a fieldable => TRUE definition. May I add that definition from my custom module and tell uc_order_product is fieldable? This is uc_order_product entity definition in the uc_order.module.
'uc_order_product' => array(
'label' => t('Order product'),
'base table' => 'uc_order_products',
'controller class' => 'UcOrderProductController',
'metadata controller class' => 'UcOrderProductMetadataController',
'entity keys' => array(
'id' => 'order_product_id',
'label' => t('Order product'),
),
'bundles' => array(
'uc_order_product' => array(
'label' => t('Order product'),
),
),
'view modes' => array(
'full' => array(
'label' => t('Normal view'),
),
'cart' => array(
'label' => t('Cart view'),
),
),
// Entity API callbacks.
'access callback' => 'uc_order_order_product_access',
'save callback' => 'uc_order_product_entity_save',
'deletion callback' => 'uc_order_product_delete',
)
Finally, I am trying to hook to this entity when it gets updated (hook_entity_update, hook_entity_presave) but they never get called on uc_order_product update. How can I hook to this entity when it is being saved, or when it has been saved? Thank you!