Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It seems that there are no product tokens available for use in the threshold mail. I.e. I tried [model] which doesn't get replaced. I think it's because of line 245 at uc_stock.module:
$token_filters = array('global' => NULL, 'order' => $order, 'stock' => $stock);
Function _uc_stock_send_mail() is documented with three parameters "$order, $product and $stock". But it's implemented with $product missing.
Please add this parameter, thanks!
Comment | File | Size | Author |
---|---|---|---|
#12 | 791028-uc_stock-product-token-test.patch | 2.36 KB | longwave |
#10 | ubercart-enable_product_tokens_for_stock_threshold_mail-791028-10.patch | 2.62 KB | mitrpaka |
#5 | uc_stock.module.02.patch | 1.44 KB | haggins |
#4 | uc_stock.module.patch | 1.55 KB | haggins |
Comments
Comment #1
TR CreditAttribution: TR commentedComment #2
haggins CreditAttribution: haggins commentedThis issue obtains on dev-version, too.
Comment #3
haggins CreditAttribution: haggins commentedreply at the same time ;)
Comment #4
haggins CreditAttribution: haggins commentedHere's a patch.
Since uc_product_token_values() needs a full node-object you have to load the products node at uc_stock_decrement_product_stock().
uc_product will then replace [model] and all other product-tokens with their values.
Mostly [model] will be replaced with the expected value. If not you can use [stock-model] if you want to get the sold products model.
Sometime there may be situations where both is not the value you want to mail in the threshold mail or save at the order comments.
Just imagine you sell tickets for a concert with two price categorys "adults" and "children". They will share the same stock of course (maybe even on n days => n stocks). This could be managed of a custom module which should have the chance to hook into and rename the model or change other properties. This would imho be the most abstract solution at this point.
Comment #5
haggins CreditAttribution: haggins commentedI'm sorry, here's a new one. With patch of #4 token [model] did not have the behavior as expected. With this one you get the nodes model by default (until you hook into).
Comment #6
haggins CreditAttribution: haggins commentedHmm, I've got another suggestion:
Don't introduce a new hook but don't let the information in $product get lost. So there are two alternatives:
"node" type contains a full node which is needed by uc_product to replace all product-tokens.
"product" could be used to give modules a chance to introduce additional token.
Advantage: more information available
Disadvantage: each type fires a new hook_token_values()
So other modules can implement hook_token_values(), too. Since $product data is available in node-type it's possible to introduce new tokens without an extra hook invocation.
I think we should not loose any data at this point to offer more flexibility.
What do you think?
Comment #7
TR CreditAttribution: TR commentedLet's sic the testbot on this one. It's going to fail due to the age of the patch, but it's a start ...
Comment #8
TR CreditAttribution: TR commentedComment #10
mitrpaka CreditAttribution: mitrpaka commentedHere is updated patch based on #5 and #6. No additional features introduced/provided, just plain fix to enable product tokens in stock threshold mail. (Same could be applied to 7.x-3.x as well)
Comment #11
longwaveThanks for the patch - I finally committed #10 with minor changes for coding standards. Also committed a followup to show node and product tokens in the token help page.
Needs porting to 7.x-3.x.
Comment #12
longwavePorted and committed to 7.x in http://drupalcode.org/project/ubercart.git/commitdiff/85c1f7d
The attached patch changes the default stock notification mail to include the product title, along with a set of tests.
Comment #13
longwaveCommitted to 7.x-3.x.
Comment #14
longwavePorted and committed to 6.x-2.x.