This a follow-up of #660376: profile tokens against default addresses.

The address tokens from default addresses should be available in user context. This feature is already available for the 6.x-1.x and 6.x-2.x versions, but it still needs to be implemented for 7.x-1.x. The token system has changed in Drupal 7, so it has to be implemented differently. For developers that are experienced with integrating modules with the token module this should be an easy one to implement.

This issue is here for volunteers to be picked up. Assign yourself to the issue first if you want to work on this one. This issue needs to be fixed prior to the release of 7.x-1.0-alpha1.

Comments

Michael-IDA’s picture

Hello World,

After talking with MegaChriz, we're offering a $ bonus to whoever can do this:

Deliverable:
- Implement all tokens currently existing in the 6.x branch into the 7.x branch of Ubercart Addresses 

Please send me an email off my contact form with a flat dollar amount bid and expected completion date.

# # #
MegaChriz,

If you desire any additional tokens, please add them here (quickly), and I can add them into this bonus.

Best,
Sam

megachriz’s picture

Basically, all the tokens are already there. The only thing that still needs to happen is to get the address tokens from the default addresses available in user context. This is probably very simple. I believe it just as simple as adding two user tokens and make them of type 'uc_addresses'. I've already defined these two user tokens in uc_addresses_token_info(), but I've not implemented them yet in uc_addresses_tokens() (nor did I test yet if I defined the two user tokens completely right).

Michael-IDA’s picture

$25 Bonus for fixing uc_addresses, user tokens

http://groups.drupal.org/node/207918
http://drupal.org/node/1430212

Hello Drupallers,

We're offering a bonus to the first person that can submit a successful quick fix patch(s) for this module:

Module: Ubercart Addresses
http://drupal.org/project/uc_addresses

Issue: Ubercart Addresses user tokens
http://drupal.org/node/1424032

Bonus: $25
Deadline: Feb. 13, 2012

Please submit your patch to the issue queue and I will do the testing/QA. Once accepted by MegaChriz (module owner), we'll PayPal you the bonus. After the deadline, we'll pay half, but I'll be working on it then as well...

Please add any module specific questions to the issue queue.

Best Regards,

Sam

PS: There are two others we are currently bonus-ing for uc_addresses, and if you can do all three, the total bonus will be bumped to $300.

Order administration feature
http://drupal.org/node/1424038
Bonus: $150
Deadline: Feb. 13, 2012

Delivery information does not display in checkout
http://drupal.org/node/1421720
Bonus: $60
Deadline: Feb. 13, 2012

mwsam’s picture

StatusFileSize
new1.05 KB

This patch adds the missing user's default address tokens.

megachriz’s picture

Status: Active » Needs work

Thanks for the patch, but it's not complete yet. While [user:default-billing-address] and [user:default-shipping-address] gets replaced correctly (thanks for that), "subtokens" like [user:default-billing-address:last_name] and [user:default-shipping-address:country] does not get replaced.

I used the following code to test the user token implementation:

$data['user'] = user_load(1);
$text = "[user:default-billing-address:last_name]\n[user:default-shipping-address:country]";
$replaced = token_replace($text, $data);
print $replaced;

This results into:

[user:default-billing-address:last_name]
[user:default-shipping-address:country]
mwsam’s picture

StatusFileSize
new1.18 KB

Updated with sub-tokens replacement.

mwsam’s picture

Status: Needs work » Needs review
Michael-IDA’s picture

will test in about 2 hrs. sam
Edit: well that didn't happen....

Michael-IDA’s picture

Status: Needs review » Reviewed & tested by the community

Hi MegaChriz,

These tested okay:

[current-user:default-billing-address:address_name]
[current-user:default-billing-address:aid]
[current-user:default-billing-address:city]
[current-user:default-billing-address:company]
[current-user:default-billing-address:country]
[current-user:default-billing-address:created]
[current-user:default-billing-address:last_name]

[user:default-billing-address:aid]
[user:default-shipping-address:first_name]

so, looks good to me. If you don't see a problem in any of the others, I think we can call this good.

mwsam,

Please send me your payment method/info through my drupal contact form.

Thanks,

Sam

megachriz’s picture

Status: Reviewed & tested by the community » Fixed

I've made one small change to the patch: instead of calling uc_addresses_tokens() for generating the subtokens, I used token_generate(). This way, any address tokens added by other modules will also work in user context.

I've also added an automated test to test the token replacement.

See commit.

Michael-IDA’s picture

Thanks MegaChriz,
Sam

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