The following Tokens are currently defined in commerce/modules/product/commerce_product.tokens.inc:

[product:product-id]
[product:sku]
[product:type] (the human readable type name)
[product:title]
[product:edit-url] (the absolute URL to the edit form defined by Product UI... hmm, I'm guessing this should be moved to the UI module!)
[product:created] (this is a date Token that can be extended, i.e. [product:created:short]... defaults to medium)

This list does not include Tokens for the changed date or for the product creator, two default values of the product object. Furthermore, as mentioned above, the edit-url Token should be moved to a Token include file for the Product UI module and have an additional view-url Token added. This will go to the currently non-existent View page once #733044: Add build modes for products gains traction.

Are there any other Tokens that need to be added here? Does anyone know what we'll need to do for Tokens defined by Fields?

Patches welcome. : )

CommentFileSizeAuthor
#2 commerce-733356.patch4.52 KBbendiy

Comments

rszrama’s picture

Ahh, and any additional Tokens will need to have Test coverage; see the testCommerceProductTokens() function in commerce_product.test.

bendiy’s picture

Status: Active » Needs review
StatusFileSize
new4.52 KB

Attached is a patch that can serve as a first pass as this issue. I'm not sure if $product_ui should stay as $product in some places.

bendiy’s picture

Here's a list of possible additional tokens. Some will probably be defined by additional fields:

  1. Item is Sold - However, this probably needs to be more than just a token
  2. Description
  3. UPC Code
  4. Unit of Measure
  5. Images
  6. Weight
  7. Category
  8. Quantity in Stock
  9. Tariff Code
dave reid’s picture

+++ modules/product/commerce_product.tokens.inc	9 Mar 2010 22:20:08 -0000
@@ -34,9 +34,9 @@ function commerce_product_token_info() {
+  $product['uid'] = array(
+    'name' => t('Created By'),
+    'description' => t('The uid of the product creator'),

Why not rather make a [product:creator] chained token that's a 'user' token type? That way you can have [product:creator:uid] automatically.

Powered by Dreditor.

pcambra’s picture

Issue tags: +dcsprint5
rszrama’s picture

Issue tags: -tokens, -products
rszrama’s picture

Status: Needs review » Needs work

Oh, and agreed with Dave above. We should use the chained Token - see this commit filling out missing order tokens as an example:

https://github.com/rszrama/drupalcommerce/commit/9c00eedb151928710fa98d8...

pcambra’s picture

Status: Needs work » Needs review

I think that only the product author was missing.

https://github.com/pcambra/drupalcommerce/commit/8372ea44fb98473d19c376c...

rszrama’s picture

Status: Needs review » Fixed

Excellent; committed, though I did change it to "Creator" in conjunction with the schema and entity property definition.

Status: Fixed » Closed (fixed)
Issue tags: -low-hanging fruit, -dcsprint5

Automatically closed -- issue fixed for 2 weeks with no activity.

kenorb’s picture