Skip to main content

Using Ubercart's hook_product_description_alter() function to Update the cart_view_form and cart_checkout_form

I'm in the process of building a custom Ubercart module that allows users to dynamically enter sizes using Ubercart's uc_attributes module. The problem I ran into is that I needed to theme these custom attributes in the cart_view_form and cart_checkout_form to add a suffix behind value. Initially I overwrote the original theme file in my module using the phptemplate_ prefix. This worked great, however, after further consideration I realized the flaw in this logic. Overriding the theme like this would not allow other user's to override that theme file. So back to the drawing board I went.

My next thought was to use hook_form_alter(). This would normally work well, however, after examining the uc_cart_view form, the attributes were already themed in their html list.

So I began inspecting the uc_attribute module's code to see if there was a hook function that I was missing. I came across this function: hook_product_description_alter(). This function allowed me to change the theme file for the attributes that I was looking for. So I changed my phptemplate theme override to a custom theme function and began using this function for the attributes in question.

The next step is to find where the order invoice and order screen attributes are themed.