> For the complete documentation index, see [llms.txt](https://docs.yaycommerce.com/yaymail/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yaycommerce.com/yaymail/addons/conditional-logic/new-conditional-logic-class.md).

# New Conditional Logic Class

1. **Create a new class extend from:** `YayMailAddonConditionalLogic\Abstracts\BaseConditionalLogic`

```php
<?php

use YayMailAddonConditionalLogic\SingletonTrait;
use YayMailAddonConditionalLogic\Abstracts\BaseConditionalLogic;

/**
 * New Conditional Logic
 */
class NewConditionalLogic extends YayMailAddonConditionalLogic\Abstracts\BaseConditionalLogic {
    use SingletonTrait;

    protected function __construct() {
        parent::__construct(
            'new_logic', // Unique key.
            __( 'Conditional logic title', 'yaymail' ), // Title in UI
            'single_select'
        );
    }

    public function get_options() {
        $options = [
            [
                'label' => 'Option 1',
                'value' => 'option_1',
            ],
            [
                'label' => 'Option 2',
                'value' => 'option_2',
            ]
        ];
        return $options;
    }
    
    public function check_logic( $args ) {
        // If this function return true -> Conditional logic is true then the element containing this logic will be displayed when sending mail.
        $condition                 = $args['condition'];
        $order                     = $args['order'];
        $condition_value           = $condition['value'];

        return true;
    }
}

```

2. **Construct function**

You need to get params for the parent construct ($logic\_key, $title,  $value\_type)

* **Logic key (string):** This is a unique identifier for the conditional logic
* **Title (string):** Short text describing the meaning of the conditional logic
* **Value type:** This variable will contain one of the following values&#x20;

  ```
  number | text | single_select | multiple_select
  ```

3. **Get Options function**

This function retrieves the options value for the conditional logic. It returns an array where each item has a label and a value.\
\
If the value type is text or number, you don’t need to write this function.

4. **Check logic function**

This function runs when the email is rendered. The template will be displayed if this function returns `true`. You can retrieve some input values to process, including: `order`, `condition`.
