This module will add product attributes as uc_cart_item tokens to be used elsewhere. As of initial upload the only code to use these tokens is in the contributed Custom Price Calculation module. The combo of these two modules allows an admin to set up custom code to set item properties such as price based on attributes.
One use could be setting up an attribute with no options on a product called donation which would in turn generate a token called [donation] and would add a text box for a customer to enter a donation amount to add to the product price. This could then be used by the Custom Price module with the following code inserted...
$item->price += [donation];You'd want to do validation and formatting here as well since [donation] is going to be any text that a user could enter and this expects a 2 decimal place number with no leading dollar sign.
Another use might be for implementing complex logic beyond just +1.00 or -2.00 for attribute price adjustments. Within the custom code block you can reference all of the attribute values and make adjustments based on the exact combo of attributes selected. For instance, if you only want to charge $1.00 extra for a (large, black) t-shirt but a (large, red) and a (medium, black) will sell for regular price you can set all of the product attributes to 0 price adjustment and then add the following custom code...
if('[size]' == 'large' && '[color]' == 'black') {
$item->price += 1;
}*I believe this could cause problems if you happen to name your attributes the same as existing tokens generated elsewhere. Perhaps tokens generated here should be prefixed attr_
| Attachment | Size |
|---|---|
| uc_attribute_tokens.zip | 1.11 KB |

