Are there any plans to add token support?
It would be really useful if there was something like [commerce-order:commerce-customer-billing:commerce-customer-address:phone_number].

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

No plan now. But patch is of course welcome.

deviantintegral’s picture

Component: Miscellaneous » Code
Issue summary: View changes
Status: Active » Needs review
FileSize
2.28 KB

Tada!

jcisio’s picture

I don't have time now to test, but the patch looks good and self explained. Anyone can test?

stonk’s picture

I have added this to our site and, so far, it seems to be working perfectly. If I find any faults I will report them here.

Thanks for the patch.

Zoltan Komar’s picture

If apply this patch, i got other problem with address fields. And when i got order report e-mail, the Name, State, Stree etc field change "Array" result.

ericjenkins’s picture

I had the same problem as zedspeirs, where my phone number tokens worked but my other addressfield tokens began displaying "Array" instead of the correct token values. I fixed it by adding a nested if statement to the patch, like so:

foreach ($tokens as $token => $raw) {
  if($token=='phone-number' || $token=='phone-number-extension' || $token=='mobile-number' || $token=='fax-number') {
    // Our token names are just the field properties with dashes, so we can
    // skip having to do any sort of if / switching on them.
    $property = str_replace('-', '_', $token);
    $replacements[$raw] = $address_field[LANGUAGE_NONE][0][$property];
  }
}

I am not sure if this change is the ideal way to fix this bug. But it's working for me, pending further testing.

Zoltan Komar’s picture

Yep, #6 patch working fine.

ericjenkins’s picture

Attached is a proper patch file reflecting my change noted in #6.

  • jcisio committed 9e76212 on 7.x-1.x
    Issue #1969696 by ericjenkins, deviantintegral, jcisio: Token support
    
jcisio’s picture

Status: Needs review » Fixed

Thanks. I've fixed some coding standard, add support for the language option etc. to keep synchronized with Addressfield token support.

Status: Fixed » Closed (fixed)

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