I am designing an apparel website that will have have products in multiple size and style combinations. Each product has a design, and I have two attributes, Size and Style, on which customers choose the subproduct they want.
I'm using Taxonomy to develop my product catalog. Some of the categories I'd like to define are consistent at the product level (i.e. a red shirt is always red), but other categories are dependent upon the availability of certain attribute combinations. Accordingly, what I'd like to do is have a taxonomy term for each attribute combination, and use workflow_ng to set/unset that term when a subproduct becomes available or sells out.
I was taking a look at the uc_stock module, and saw that it uses workflow_ng to send an email when the stock threshold is met. My idea was that I could update that action to remove from the product any taxonomy terms associated with attribute combinations that have reached the threshold. However, I am not a coder and I'm having quite a bit of difficulty figuring out how to get this together.
The second half of this task will be to create an action that sets the taxonomy terms for products are available, but I suspect that a lot of that code will flow naturally from the code used in this action.
This is my (very preliminary) code at present, which updates the function found in uc_stock_workflow.inc:
function uc_stock_action_decrement_stock($order, $settings) {
stock_warnings = array();
foreach ($order->products as $product) {
if (($stock = uc_stock_level($product->model)) !== FALSE) {
$stock_level = db_fetch_object(db_query("SELECT * FROM {uc_product_stock} WHERE sku = '%s'",$product->model));
if ((($stock-$product->qty) <= $stock_level->threshold) && !in_array($product->model,array_keys($stock_warnings)) ) {
$stock_level->stock -= $product->qty;
$stock_warnings[$product->model] = $stock_level;
}
uc_stock_adjust($product->model,-$product->qty);
uc_order_comment_save($order->order_id, 0, t('The stock level for %model_name has been decreased to !qty',array('%model_name' => $product->model,'!qty' => ($stock - $product->qty))));
}
}
if (!empty($stock_warnings) && variable_get('uc_stock_threshold_notification',FALSE)) {
foreach ($stock_warnings as $model => $stock_level) {
_uc_stock_send_mail($order, $stock_level);
/******* My code starts here *******/
/* How is this done? */
$type_tid = _taxonomy_get_tid_from_term();
$term_list = taxonomy_node_get_terms($node->nid);
foreach ($term_list as $term) {
if ($term['tid']==$type_tid) {
unset $term;
}
}
taxonomy_node_save($node->nid, $term_list);
}
}
}The issues I'm trying to work through:
- How to get a set of attributes by subproduct SKU?
- How to reference those attributes to their name values?
- How to deal with taxonomy terms that appear multiple times in a hierarchical vocabulary?
Anyone have any ideas? Alternatively, does anyone else have a use for this type of feature who might want to take it over? Like I said, I'm really not a coder... 




Joined: 03/02/2008