[Drupal] How to create a custom line item type programatically?
In one of my recent projects i came across a situation where i had to create a order line item programatically. If you have ever came across such a situation you would end up in line_item_example.module which demonstrate the addition of a new line item type programatically.
I followed the steps specified in the line item example module but the commerce_unit_price and commerce_total fields were not added to my line item.
On further debugging i found out that this happened as my line item was created in a disabled status
In order to enable my line item i have to call the function,
This function is called whenever a module is enabled. As i created my line item in a custom module which was already enabled, this function was not called and my line item was in disabled status
Hence i wrote a update hook and run the above function
My line item is enabled. Hope this helps some one