Answers.Body: <p>For anyone interested in why this didn't work...It appears that you can't include a filter in the twig statement for discount formula conditions, at least not |date() as I was using. The error message in the CP isn't so great since it is valid twig syntax, but I totally get not using filters in this situation.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-11T02:47:50.850Z
Answers.LastActivityDate: 2020-12-11T02:47:50.850Z
Answers.UserDisplayName: cbad
Answers.Body: <p>Looks like you're missing the <code>if</code> conditional?</p>
  <p>Try this:</p>
  <pre><code>{% if cart.eDate|date('D') in ['Tue'] %}
      Tuesday's discount!
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-08T05:22:36.410Z
Answers.Text: Yea, that didn't work either, but thank you! I didn't have the 'if' because I was thinking the Order Condition Formula needed a boolean value to qualify the discount. The placeholder shows something like this: '@apple.com' in order.email
Answers.UserDisplayName: cbad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-08T15:30:03.753Z
Answers.Text: Just to elaborate a bit further, my thinking was the Condition Formula would provide a conditional that Commerce would then wrap an if around when evaluating whether to apply the discount or not. Maybe that's flawed thinking?
Answers.UserDisplayName: cbad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-07T23:00:43.203Z
Answers.LastActivityDate: 2020-12-07T23:00:43.203Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm trying to add a condition for a discount. It involves a custom date field. I want to discount anything that falls on Tuesday. I can't seem to get the twig syntax right. I've tried these two:</p>
  <pre><code>((cart.eDate|date('D')) == 'Tue')
  ((cart.eDate|date('D')) in ['Tue'])
  </code></pre>
  <p>I prefer the latter so I could add additional days if needed. Either of these work in templates. Is it because it is a custom field and the CP doesn't recognize it? Is there another approach?</p>
  
Tags: <plugin-craftcommerce>
Title: Trouble with twig syntax for discount conditions
ThreadText: # Trouble with twig syntax for discount conditions
  
  (Asked by: username_0 on 2020-12-07)
  
  I'm trying to add a condition for a discount. It involves a custom date field. I want to discount anything that falls on Tuesday. I can't seem to get the twig syntax right. I've tried these two:
  
  ```
  ((cart.eDate|date('D')) == 'Tue')
  ((cart.eDate|date('D')) in ['Tue'])
  
  ```
  
  I prefer the latter so I could add additional days if needed. Either of these work in templates. Is it because it is a custom field and the CP doesn't recognize it? Is there another approach?
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-12-11. Score: 1
  
  For anyone interested in why this didn't work...It appears that you can't include a filter in the twig statement for discount formula conditions, at least not |date() as I was using. The error message in the CP isn't so great since it is valid twig syntax, but I totally get not using filters in this situation.
  
  
  ---
  
  ### Answer by username_1 on 2020-12-07. Score: 0
  
  Looks like you're missing the `if` conditional?
  
  Try this:
  
  ```
  {% if cart.eDate|date('D') in ['Tue'] %}
      Tuesday's discount!
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Yea, that didn't work either, but thank you! I didn't have the 'if' because I was thinking the Order Condition Formula needed a boolean value to qualify the discount. The placeholder shows something like this: '@apple.com' in order.email  
  > **username_0**: Just to elaborate a bit further, my thinking was the Condition Formula would provide a conditional that Commerce would then wrap an if around when evaluating whether to apply the discount or not. Maybe that's flawed thinking?  
  
  ---
  
  