This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | if ( ! defined( 'ABSPATH' ) ) { |
||
4 | exit; // Exit if accessed directly |
||
5 | } |
||
6 | |||
7 | if ( ! class_exists( 'WC_Email_Customer_Completed_Order' ) ) : |
||
8 | |||
9 | /** |
||
10 | * Customer Completed Order Email. |
||
11 | * |
||
12 | * Order complete emails are sent to the customer when the order is marked complete and usual indicates that the order has been shipped. |
||
13 | * |
||
14 | * @class WC_Email_Customer_Completed_Order |
||
15 | * @version 2.0.0 |
||
16 | * @package WooCommerce/Classes/Emails |
||
17 | * @author WooThemes |
||
18 | * @extends WC_Email |
||
19 | */ |
||
20 | class WC_Email_Customer_Completed_Order extends WC_Email { |
||
21 | |||
22 | /** |
||
23 | * Constructor. |
||
24 | */ |
||
25 | public function __construct() { |
||
26 | |||
27 | $this->id = 'customer_completed_order'; |
||
28 | $this->customer_email = true; |
||
29 | $this->title = __( 'Completed order', 'woocommerce' ); |
||
30 | $this->description = __( 'Order complete emails are sent to customers when their orders are marked completed and usually indicate that their orders have been shipped.', 'woocommerce' ); |
||
31 | |||
32 | $this->heading = __( 'Your order is complete', 'woocommerce' ); |
||
33 | $this->subject = __( 'Your {site_title} order from {order_date} is complete', 'woocommerce' ); |
||
34 | |||
35 | $this->template_html = 'emails/customer-completed-order.php'; |
||
36 | $this->template_plain = 'emails/plain/customer-completed-order.php'; |
||
37 | |||
38 | // Triggers for this email |
||
39 | add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ) ); |
||
40 | |||
41 | // Other settings |
||
42 | $this->heading_downloadable = $this->get_option( 'heading_downloadable', __( 'Your order is complete - download your files', 'woocommerce' ) ); |
||
43 | $this->subject_downloadable = $this->get_option( 'subject_downloadable', __( 'Your {site_title} order from {order_date} is complete - download your files', 'woocommerce' ) ); |
||
44 | |||
45 | // Call parent constuctor |
||
46 | parent::__construct(); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Trigger. |
||
51 | * |
||
52 | * @param int $order_id |
||
53 | */ |
||
54 | public function trigger( $order_id ) { |
||
55 | |||
56 | if ( $order_id ) { |
||
57 | $this->object = wc_get_order( $order_id ); |
||
0 ignored issues
–
show
|
|||
58 | $this->recipient = $this->object->billing_email; |
||
59 | |||
60 | $this->find['order-date'] = '{order_date}'; |
||
61 | $this->find['order-number'] = '{order_number}'; |
||
62 | |||
63 | $this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) ); |
||
64 | $this->replace['order-number'] = $this->object->get_order_number(); |
||
65 | } |
||
66 | |||
67 | if ( ! $this->is_enabled() || ! $this->get_recipient() ) { |
||
68 | return; |
||
69 | } |
||
70 | |||
71 | $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Get email subject. |
||
76 | * |
||
77 | * @access public |
||
78 | * @return string |
||
79 | */ |
||
80 | View Code Duplication | public function get_subject() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
81 | if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) { |
||
82 | return apply_filters( 'woocommerce_email_subject_customer_completed_order', $this->format_string( $this->subject_downloadable ), $this->object ); |
||
83 | } else { |
||
84 | return apply_filters( 'woocommerce_email_subject_customer_completed_order', $this->format_string( $this->subject ), $this->object ); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Get email heading. |
||
90 | * |
||
91 | * @access public |
||
92 | * @return string |
||
93 | */ |
||
94 | View Code Duplication | public function get_heading() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
95 | if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) { |
||
96 | return apply_filters( 'woocommerce_email_heading_customer_completed_order', $this->format_string( $this->heading_downloadable ), $this->object ); |
||
97 | } else { |
||
98 | return apply_filters( 'woocommerce_email_heading_customer_completed_order', $this->format_string( $this->heading ), $this->object ); |
||
99 | } |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Get content html. |
||
104 | * |
||
105 | * @access public |
||
106 | * @return string |
||
107 | */ |
||
108 | public function get_content_html() { |
||
109 | return wc_get_template_html( $this->template_html, array( |
||
110 | 'order' => $this->object, |
||
111 | 'email_heading' => $this->get_heading(), |
||
112 | 'sent_to_admin' => false, |
||
113 | 'plain_text' => false, |
||
114 | 'email' => $this |
||
115 | ) ); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * Get content plain. |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | public function get_content_plain() { |
||
124 | return wc_get_template_html( $this->template_plain, array( |
||
125 | 'order' => $this->object, |
||
126 | 'email_heading' => $this->get_heading(), |
||
127 | 'sent_to_admin' => false, |
||
128 | 'plain_text' => true, |
||
129 | 'email' => $this |
||
130 | ) ); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Initialise settings form fields. |
||
135 | */ |
||
136 | public function init_form_fields() { |
||
137 | $this->form_fields = array( |
||
138 | 'enabled' => array( |
||
139 | 'title' => __( 'Enable/Disable', 'woocommerce' ), |
||
140 | 'type' => 'checkbox', |
||
141 | 'label' => __( 'Enable this email notification', 'woocommerce' ), |
||
142 | 'default' => 'yes' |
||
143 | ), |
||
144 | 'subject' => array( |
||
145 | 'title' => __( 'Subject', 'woocommerce' ), |
||
146 | 'type' => 'text', |
||
147 | 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject ), |
||
148 | 'placeholder' => '', |
||
149 | 'default' => '', |
||
150 | 'desc_tip' => true |
||
151 | ), |
||
152 | 'heading' => array( |
||
153 | 'title' => __( 'Email Heading', 'woocommerce' ), |
||
154 | 'type' => 'text', |
||
155 | 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading ), |
||
156 | 'placeholder' => '', |
||
157 | 'default' => '', |
||
158 | 'desc_tip' => true |
||
159 | ), |
||
160 | 'subject_downloadable' => array( |
||
161 | 'title' => __( 'Subject (downloadable)', 'woocommerce' ), |
||
162 | 'type' => 'text', |
||
163 | 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject_downloadable ), |
||
164 | 'placeholder' => '', |
||
165 | 'default' => '', |
||
166 | 'desc_tip' => true |
||
167 | ), |
||
168 | 'heading_downloadable' => array( |
||
169 | 'title' => __( 'Email Heading (downloadable)', 'woocommerce' ), |
||
170 | 'type' => 'text', |
||
171 | 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading_downloadable ), |
||
172 | 'placeholder' => '', |
||
173 | 'default' => '', |
||
174 | 'desc_tip' => true |
||
175 | ), |
||
176 | 'email_type' => array( |
||
177 | 'title' => __( 'Email type', 'woocommerce' ), |
||
178 | 'type' => 'select', |
||
179 | 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), |
||
180 | 'default' => 'html', |
||
181 | 'class' => 'email_type wc-enhanced-select', |
||
182 | 'options' => $this->get_email_type_options(), |
||
183 | 'desc_tip' => true |
||
184 | ) |
||
185 | ); |
||
186 | } |
||
187 | } |
||
188 | |||
189 | endif; |
||
190 | |||
191 | return new WC_Email_Customer_Completed_Order(); |
||
192 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.