Order_Email::setOrder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
nop 1
1
<?php
2
3
4
/**
5
 * @Description: Email specifically for communicating with customer about order.
6
 *
7
 *
8
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
9
 * @package: ecommerce
10
 * @sub-package: email
11
 * @inspiration: Silverstripe Ltd, Jeremy
12
 **/
13
abstract class Order_Email extends Email
14
{
15
    /**
16
     * @var Order
17
     */
18
    protected $order = null;
19
20
    /**
21
     * @var bool
22
     */
23
    protected $resend = false;
24
25
    /**
26
     * turns an html document into a formatted html document
27
     * using the emogrify method.
28
     *
29
     * @param $html
30
     *
31
     * @return string HTML
32
     */
33
    public static function emogrify_html($html)
34
    {
35
        //get required files
36
        $baseFolder = Director::baseFolder();
37
        if (!class_exists('\Pelago\Emogrifier')) {
38
            require_once $baseFolder.'/ecommerce/thirdparty/Emogrifier.php';
39
        }
40
        $cssFileLocation = Director::baseFolder().'/'.EcommerceConfig::get('Order_Email', 'css_file_location');
41
        $cssFileHandler = fopen($cssFileLocation, 'r');
42
        $css = fread($cssFileHandler, filesize($cssFileLocation));
43
        fclose($cssFileHandler);
44
        $emogrifier = new \Pelago\Emogrifier($html, $css);
45
        $html = $emogrifier->emogrify();
46
        //make links absolute!
47
        $html = HTTP::absoluteURLs($html);
48
49
        return $html;
50
    }
51
52
    /**
53
     * returns the standard from email address (e.g. the shop admin email address).
54
     *
55
     * @return string
56
     */
57
    public static function get_from_email()
58
    {
59
        $ecommerceConfig = EcommerceDBConfig::current_ecommerce_db_config();
60
        if ($ecommerceConfig && $ecommerceConfig->ReceiptEmail) {
0 ignored issues
show
Documentation introduced by
The property ReceiptEmail does not exist on object<EcommerceDBConfig>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
61
            $email = $ecommerceConfig->ReceiptEmail;
0 ignored issues
show
Documentation introduced by
The property ReceiptEmail does not exist on object<EcommerceDBConfig>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
62
        } else {
63
            $email = Email::config()->admin_email;
64
        }
65
66
        return trim($email);
67
    }
68
69
    /**
70
     * returns the subject for the email (doh!).
71
     *
72
     * @return string
73
     */
74
    public static function get_subject()
75
    {
76
        $siteConfig = SiteConfig::current_site_config();
77
        if ($siteConfig && $siteConfig->Title) {
78
            return _t('Order_Email.SALEUPDATE', 'Sale Update for Order #[OrderNumber] from ').$siteConfig->Title;
79
        } else {
80
            return _t('Order_Email.SALEUPDATE', 'Sale Update for Order #[OrderNumber] ');
81
        }
82
    }
83
84
    /**
85
     * set the order associated with the email.
86
     *
87
     * @param Order $order - the order to which the email relates
88
     */
89
    public function setOrder(Order $order)
90
    {
91
        $this->order = $order;
92
    }
93
94
    /**
95
     * sets resend to true, which means that the email
96
     * is sent even if it has already been sent.
97
     */
98
    public function setResend($resend = true)
99
    {
100
        $this->resend = $resend;
101
    }
102
103
    /**
104
     * @param null|string $messageID      - ID for the message, you can leave this blank
105
     * @param bool        $returnBodyOnly - rather than sending the email, only return the HTML BODY
106
     *
107
     * @return bool - TRUE for success and FALSE for failure.
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null|string[]|false?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
108
     */
109
    public function send($messageID = null, $returnBodyOnly = false)
110
    {
111
        if (!$this->order) {
112
            user_error('Must set the order (Order_Email::setOrder()) before the message is sent (Order_Email::send()).', E_USER_NOTICE);
113
        }
114
        if (!$this->subject) {
115
            $this->subject = self::get_subject();
116
        }
117
        $this->subject = str_replace('[OrderNumber]', $this->order->ID, $this->subject);
118
        if ((!$this->hasBeenSent()) || ($this->resend)) {
119
            if (EcommerceConfig::get('Order_Email', 'copy_to_admin_for_all_emails') && ($this->to !== self::get_from_email())) {
120
                if ($memberEmail = self::get_from_email()) {
121
                    $array = [ $memberEmail ];
122
                    if($bcc = $this->Bcc()) {
123
                        $array[] = $bcc;
124
                    }
125
                    $this->setBcc(implode(", ", $array));
126
                }
127
            }
128
            //last chance to adjust
129
            $this->extend('adjustOrderEmailSending', $this, $order);
130
            if ($returnBodyOnly) {
131
                return $this->Body();
132
            }
133
            $orderEmailRecord = $this->createRecord($result);
0 ignored issues
show
Bug introduced by
The variable $result seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
134
            if (EcommerceConfig::get('Order_Email', 'send_all_emails_plain')) {
135
                $result = parent::sendPlain($messageID);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (sendPlain() instead of send()). Are you sure this is correct? If so, you might want to change this to $this->sendPlain().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
136
            } else {
137
                $result = parent::send($messageID);
138
            }
139
            $orderEmailRecord->Result = $result;
0 ignored issues
show
Documentation introduced by
The property Result does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
140
            $orderEmailRecord->write();
141
142
            return $result;
143
        }
144
    }
145
146
    /**
147
     * @param bool $result: how did the email go? 1 = sent, 0 = not sent
0 ignored issues
show
Documentation introduced by
There is no parameter named $result:. Did you maybe mean $result?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
148
     *
149
     * @return DataObject (OrderEmailRecord)
150
     **/
151
    protected function createRecord($result)
152
    {
153
        $orderEmailRecord = OrderEmailRecord::create();
154
        $orderEmailRecord->From = $this->emailToVarchar($this->from);
0 ignored issues
show
Documentation introduced by
The property From does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
155
        $orderEmailRecord->To = $this->emailToVarchar($this->to);
0 ignored issues
show
Documentation introduced by
The property To does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
156
        if ($this->Cc()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->Cc() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
157
            $orderEmailRecord->To .= ', CC: '.$this->emailToVarchar($this->Cc());
0 ignored issues
show
Documentation introduced by
The property To does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
158
        }
159
        if ($this->Bcc()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->Bcc() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
160
            $orderEmailRecord->To .= ', BCC: '.$this->emailToVarchar($this->Bcc());
0 ignored issues
show
Documentation introduced by
The property To does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
161
        }
162
        //always set result to try if
163
        $orderEmailRecord->Subject = $this->subject;
0 ignored issues
show
Documentation introduced by
The property Subject does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
164
        if (!$result) {
165
            if (Director::isDev()) {
166
                $result = true;
167
                $orderEmailRecord->Subject .= _t('Order_Email.FAKELY_RECORDED_AS_SENT', ' - FAKELY RECORDED AS SENT ');
0 ignored issues
show
Documentation introduced by
The property Subject does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
168
            }
169
        }
170
        $orderEmailRecord->Content = $this->body;
0 ignored issues
show
Documentation introduced by
The property Content does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
171
        $orderEmailRecord->Result = $result ? 1 : 0;
0 ignored issues
show
Documentation introduced by
The property Result does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
172
        $orderEmailRecord->OrderID = $this->order->ID;
0 ignored issues
show
Documentation introduced by
The property OrderID does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
173
        $orderEmailRecord->OrderStepID = $this->order->StatusID;
0 ignored issues
show
Documentation introduced by
The property OrderStepID does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property StatusID does not exist on object<Order>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
174
        if ($sendAllEmailsTo = Config::inst()->get('Email', 'send_all_emails_to')) {
175
            $orderEmailRecord->To .=
0 ignored issues
show
Documentation introduced by
The property To does not exist on object<OrderEmailRecord>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
176
                _t('Order_Email.ACTUALLY_SENT_TO', ' | actually sent to: ')
177
                .$sendAllEmailsTo
178
                ._t('Order_Email.CONFIG_EXPLANATION', ' - (Email::send_all_emails_to)');
179
        }
180
        $orderEmailRecord->write();
181
182
        return $orderEmailRecord;
183
    }
184
185
    /**
186
     * converts an Email to A Varchar.
187
     *
188
     * @param string $email - email address
189
     *
190
     * @return string - returns email address without &gt; and &lt;
191
     */
192
    public function emailToVarchar($email)
193
    {
194
        $email = str_replace(array('<', '>', '"', "'"), ' - ', $email);
195
196
        return $email;
197
    }
198
199
    /**
200
     * Checks if an email has been sent for this Order for this status (order step).
201
     *
202
     * @return bool
203
     **/
204
    public function hasBeenSent()
205
    {
206
        $orderStep = $this->order->Status();
0 ignored issues
show
Bug introduced by
The method Status() does not exist on Order. Did you maybe mean get_order_status_options()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
207
        if (is_a($orderStep, Object::getCustomClass('OrderStep'))) {
208
            return $orderStep->hasBeenSent($this->order);
209
        }
210
211
        return false;
212
    }
213
214
    /**
215
     * moves CSS to inline CSS in email.
216
     *
217
     * @param bool $isPlain - should we send the email as HTML or as TEXT
218
     */
219
    protected function parseVariables($isPlain = false)
220
    {
221
        //start parsing
222
        parent::parseVariables($isPlain);
223
        if (!$isPlain) {
224
            $this->body = self::emogrify_html($this->body);
225
        }
226
    }
227
228
    /**
229
     * returns the instance of EcommerceDBConfig.
230
     *
231
     * @return EcommerceDBConfig
232
     **/
233
    public function EcomConfig()
234
    {
235
        return EcommerceDBConfig::current_ecommerce_db_config();
236
    }
237
}
238