Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I figured it out. Apparently, if you're creating a content type that is also an ubercart product class, you cannot simply follow the tutorial that I linked to above and then "tack on" ubercart stuff. According to the tutorial above, you need to implement the following hooks to create a content type from within your module:</p> <ul> <li>hook_info()</li> <li>hook_perm()</li> <li>hook_access()</li> <li>hook_form()</li> <li>hook_help()</li> </ul> <p>To create a content type that is also a product class, you need to make the following modifications to the above list:</p> <ul> <li>Remove hook_info(). Not sure why this causes a problem, but it does.</li> <li>Use hook_perm(), hook_access(), hook_form() and hook_help() as usual.</li> <li><p>Use hook_enable() (which fires when the module is enabled), and include the following code:</p> <pre><code>function uc_yourmodule_enable() { db_query("INSERT INTO {uc_product_classes} (pcid, name, description) VALUES ('%s', '%s', '%s')", 'product_class_id', 'Product Class Name', 'Product Class Description.'); node_types_rebuild(); } </code></pre></li> </ul> <p>As you can see, the snippet adds an entry to the uc_product_classes table, and I guess that's all ubercart needs.</p> <p>Finally, I've also implemented an ubercart-specific hook further down in my module: <a href="http://api.ubercart.org/api/function/hook_product_types/2" rel="nofollow noreferrer">hook_product_types()</a></p> <p>I'm just figuring this out as I go along, so I'm happy to receive corrections or suggestions.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload