2

I created a rule and a component, to send an email to my customers 7 days after their orders. This email asks them to leave a comment on the products they have purchased.

My problem: I can not retrieve the list of products in the email. With [order:commerce_line_items], the e-mail displays "No order items found".

Here is the export of my rule :

{ "rules_schedule_follow_up_email" : {
    "LABEL" : "Schedule follow-up email",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler", "entity" ],
    "ON" : { "commerce_order_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:status" ], "value" : "processing" } }
    ],
    "DO" : [
      { "schedule" : {
          "component" : "rules_send_follow_up_email",
          "date" : "now",
          "identifier" : "Follow-up email for [commerce-order:order-id]",
          "param_order" : [ "commerce-order" ]
        }
      }
    ]
  }
}

Here is the export of my component :

{ "rules_send_follow_up_email" : {
    "LABEL" : "Send follow-up email",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "order" : { "label" : "Order", "type" : "commerce_order" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : "[order:mail]",
          "subject" : "Votre avis nous int\u00e9resse",
          "message" : "[order:owner],\r\n\r\n\r\nvous recevez ce courriel car vous avez r\u00e9cemment fait un achat sur notre site. Nous aimerions avoir votre avis sur les produits que vous avez command\u00e9.\r\nC\u0027est simple et rapide, il vous suffit de cliquez sur les liens ci-dessous :\r\n\r\n[order:view-url]\r\n\r\n[order:commerce_line_items]\r\n\r\nMerci pour votre retour d\u2019exp\u00e9rience. Nous appr\u00e9cions le temps que vous prenez et nous l\u0027utiliserons activement pour am\u00e9liorer notre boutique. \r\n\r\n\r\nCordialement,\r\nL\u0027\u00e9quipe [site:name]\r\n[site:url]\r\n\r\nPour rester inform\u00e9 des nouveaut\u00e9s et b\u00e9n\u00e9ficier de nos offres promotionnelles, suivez-nous sur :\r\nhttps:\/\/www.facebook.com\/S1biosecom\r\nhttps:\/\/twitter.com\/S1biosecom\r\nhttps:\/\/plus.google.com\/+S1biosecom\r\nhttps:\/\/www.pinterest.com\/S1biosecom\r\n\r\nPS : ceci est un mail automatique, merci de ne pas y r\u00e9pondre.",
          "language" : [ "order:owner:language" ]
        }
      }
    ]
  }
}

I want to display in my email, the links to the product pages ordered by my client. How can I do so?

1 Answer 1

0

If what you're looking for (= the list of products) is not available, then just (a) make it available first and (b) wait with your Schedule Rules Component action (to send an eMail) until it is available. Read on for more details ...

The trick to do so is similar to what is shown in the Rules example included in my answer to "How to concatenate all token values of a list in a single field within a Rules loop?". In your case, you could make it work like so:

  1. Add some new Rules variable that will be used later on as part of the eMail body, before the Rules Action to schedule the Rules Component. Say you name the variable prod_list_var_for_email_body.
  2. Add a loop to iterate over the list of links to the product pages. Within that loop, for each iteration, prepend or append the value for each list_item to that variable prod_list_var_for_email_body (see where we're going???).
  3. Make sure that the Schedule Rules Component action is your last Rules Action, after the loop completed. And finetune the details (configuration) of your Rules Action to Schedule Rules Component. When doing so, you'll be able to select the token for file_list_var_for_email_body to include anywhere in your eMail body.

Easy, no?

4
  • It's easy for you. I do not understand the loop.
    – user54067
    Commented Jan 26, 2017 at 21:17
  • Poor @Mathieu ... sorry to make you struggle/suffer .. Just to be sure: do you know which token you have available in your rule, which contains that "list of links to product pages"? Also, are you familiar with Rules "debugging" (to find out the content (values) of any of the available tokens)? Let me know so that I know from where to start to refine/rework my answer, ca va? Commented Jan 26, 2017 at 21:32
  • In my question I exported the rule and my component. A token is present in replacing patterns for command [order: commerce_line_items] but returns "No order items found". Yet this seems logical. To summarize, the rule and component work, but it lacks in the email links to the products page.
    – user54067
    Commented Jan 26, 2017 at 22:47
  • Do you have time to show me the rules exported ?
    – user54067
    Commented Feb 1, 2017 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.