4 replies [Last post]
leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Was this information Helpful?

(This was a post about auto-SKU, but I have moved on to a different solution to the same problem. No need for auto-SKUing which is good because I couldn't get it to work anyway.)

I don't have SKUs for my products. But I want to use stock and multi-stock, so I have to use some sort of SKU-like thing. That's fine, I'll just manually make the adjustments say "blahblah-S" for small, "blahblah-M" and so on.

However! When the threshold is reached, the email that gets sent out doesn't list "title" as one of my token options. It (admin/store/help/tokens) says I can use model (AKA SKU) and cost and weight and stuff, but not title. Can I add title as a token? My "blahblah-M" will always be an abbreviation of the real title, and I'd really like the email to say, "Size Medium of the product 'Blah Blah Goes to Washington' only has 3 items left."

Thanks!
Eileen

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Can I add a new token?

Huzzah for README.TXTs!

Inside uc_product.module, there is a nice simple uc_product_token_values (and also a uc_product_token_list) that sets all the product tokens. If one is to add something like this then one can declare whatever tokens one's wee heart desires.

(in token_values)
$product_title = db_query("SELECT title FROM {node} WHERE nid = %d", $object->nid);
$product_title=db_result($product_title, $row = 0);
$tokens['product-title'] = $product_title;

(in token_list)
$tokens['product']['product-title'] = t("The product name");

Now I realize that this should go in a custom module, but I tried that and it didn't work. And I am feeling impatient. So into core code it goes. (What? Upgrade-safe? LALALA I CAN'T HEAR YOU.)

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
lol Glad you got it figured

lol Laughing out loud

Glad you got it figured out. I don't see any reason why it can't go in a custom module. You just have to make sure you rename the module and the hook function names so that instead of starting with uc_product_ they start w/ the name of your module followed by an underscore. Smiling

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: lol Glad you got it figured

That's how I started, but it didn't work. Maybe I can't append to another group's tokens (a la [product][product-title]), and I would have to create a new group? Since Stock tells me that it only uses order, stock, and product tokens, I wanted to put my token in one of those groups.

Frankly, I left upgradeable territory many moons ago, so at least for me this is a pretty decent solution. Smiling

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
leenwebb wrote:Frankly, I
leenwebb wrote:

Frankly, I left upgradeable territory many moons ago, so at least for me this is a pretty decent solution. Smiling

hehe It happens. One thing you can do if you wanna spend the time learning is make a diff of your current version of Ubercart against the original version of that release. You can then use this as a patch and patch it into the latest release to preserve your hacks. Hacks aren't always bad, but it's good to have a system for maintaining them. A lot of enterprise Drupal users have a library of patches they apply to Drupal core to make it more suited for high traffic sites.