Hello,

I have a Drupal commerce setup with three languages, french, dutch and english but for some obscure reason when an anonymous user checks out on the french or english page he/she always receives the confirmation e-mail in dutch (witch is the default language for the site).

I translated the messages the system is supposed to send in the account settings as usual using i18n variables, but those translation aren't used on anonymous checkout.
When creating a new account on the other hand the account notification e-mails are translated as they should be.

Has this something to do with the rule: "Create a new account for an anonymous order".

I couldn't find anything related to this subject in this issue thread and since it seem related to the anonymous checkout I think this is the right place to ask, so please help...

Comments

selfirian’s picture

Ok I found a solution... it was indeed the rule I mentioned, I'm posting my solution, it might save some-one some time :)

I added an action after the create a new entity rule:
the "set a data value" action I added has as parameter: Data[account-created:language] and value: [site:current-page:language]

Here's the export of my modified rule:

{ "commerce_checkout_new_account" : {
    "LABEL" : "Cr\u00e9er un nouveau compte pour une commande anonyme",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "2",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "rules", "commerce", "commerce_checkout" ],
    "ON" : { "commerce_checkout_complete" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:uid" ], "value" : "0" } },
      { "NOT entity_exists" : {
          "type" : "user",
          "property" : "mail",
          "value" : [ "commerce-order:mail" ]
        }
      },
      { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_name" : [ "commerce-order:mail-username" ],
            "param_mail" : [ "commerce-order:mail" ]
          },
          "PROVIDE" : { "entity_created" : { "account_created" : "Compte cr\u00e9\u00e9" } }
        }
      },
      { "data_set" : {
          "data" : [ "account-created:language" ],
          "value" : [ "site:current-page:language" ]
        }
      },
      { "data_set" : { "data" : [ "account-created:status" ], "value" : 1 } },
      { "entity_save" : { "data" : [ "account-created" ], "immediate" : 1 } },
      { "entity_query" : {
          "USING" : {
            "type" : "user",
            "property" : "mail",
            "value" : [ "commerce-order:mail" ],
            "limit" : 1
          },
          "PROVIDE" : { "entity_fetched" : { "account_fetched" : "Compte r\u00e9cup\u00e9r\u00e9" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "account-fetched" ] },
          "ITEM" : { "list_item" : "\u00c9l\u00e9ment de la liste courante" },
          "DO" : [
            { "send_account_email" : { "account" : [ "list-item" ], "email_type" : "register_admin_created" } },
            { "data_set" : { "data" : [ "commerce-order:uid" ], "value" : [ "list-item:uid" ] } },
            { "data_set" : {
                "data" : [ "commerce-order:commerce-customer-billing:uid" ],
                "value" : [ "list-item:uid" ]
              }
            },
            { "data_set" : {
                "data" : [ "commerce-order:commerce-customer-shipping:uid" ],
                "value" : [ "list-item:uid" ]
              }
            }
          ]
        }
      }
    ]
  }
}
rszrama’s picture

Status: Active » Fixed

Great, thanks for sharing.

selfirian’s picture

Your welcome, glad to contribute.

Status: Fixed » Closed (fixed)

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