Checking value of customer order field within Plugin I am trying to check the value of a checkbox as part of my checkout process. I have the following function at the moment.

public function init()
{
    craft()-&gt;on('commerce_orders.onBeforeOrderComplete', function (Event $event) {
        $order = $event-&gt;params['order'];
        echo '&lt;pre&gt;';
        print_r($order-&gt;signupForNewsletter);
            if ($order-&gt;signupForNewsletter == 'joinMailingList') {
                echo "I've opted in";
            } else {
                echo 'Not matched';
            }
        echo '&lt;/pre&gt;';
        exit;
    });
}


But whether the checkbox is ticked or not I am only get the 'Not matched' statement, so my if statement is always false. I have tried several things, but cannot see how to resolve this.
I think perhaps because the signupForNewsletter is a checkbox in the custom order fields, so it is an array rather than an object. 

Here is the print_r results of this code;

    Craft\MultiOptionsFieldData Object
(
    [_options:Craft\MultiOptionsFieldData:private] =&gt; Array
        (
            [0] =&gt; Craft\OptionData Object
                (
                    [label] =&gt; Join Mailing List
                    [value] =&gt; joinMailingList
                    [selected] =&gt; 1
                )

        )

    [storage:ArrayObject:private] =&gt; Array
        (
        )

    )
    Not matched


The checkbox was ticked in this instance as you can see in the value field.
What you're probably looking for is:

if ($order-&gt;signupForNewsletter-&gt;contains('joinMailingList'))
{
    echo "I've opted in";
}
else
{
    echo 'Not matched';
}