PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Elements / OrderDetails.php

OrderDetails.php in YayMail – WooCommerce Email Customizer 4.4.2, at src/Elements/OrderDetails.php

289 lines 14.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace YayMail\Elements;
3
4 use YayMail\Abstracts\BaseElement;
5 use YayMail\Constants\AttributesData;
6 use YayMail\Utils\SingletonTrait;
7
8 /**
9 * OrderDetails Elements
10 */
11 class OrderDetails extends BaseElement {
12
13 use SingletonTrait;
14
15 protected static $type = 'order_details';
16
17 public $available_email_ids = [ YAYMAIL_WITH_ORDER_EMAILS ];
18
19 public static function get_data( $attributes = [] ) {
20 $is_email_improvements_enabled = get_option( 'woocommerce_feature_email_improvements_enabled', 'no' ) === 'yes';
21 $layout_type = $is_email_improvements_enabled ? 'modern' : 'legacy';
22
23 self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20">
24 <path d="M17.5,2.5v15H2.5V2.5h15M18,1H2c-.55,0-1,.45-1,1v16c0,.55.45,1,1,1h16c.55,0,1-.45,1-1V2c0-.55-.45-1-1-1h0Z"/>
25 <path d="M18.05,8.1H1.82c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h16.23c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
26 <path d="M18.05,13.55H1.82c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h16.23c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
27 <path d="M18.05,18.99H1.82c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h16.23c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
28 <path d="M12.75,18.8c-.41,0-.75-.34-.75-.75V1.82c0-.41.34-.75.75-.75s.75.34.75.75v16.23c0,.41-.34.75-.75.75Z"/>
29 <path d="M7.27,18.8c-.41,0-.75-.34-.75-.75V1.82c0-.41.34-.75.75-.75s.75.34.75.75v16.23c0,.41-.34.75-.75.75Z"/>
30 </svg>';
31
32 $title_conditions = [
33 [
34 'value' => true,
35 'attribute' => 'show_table_header',
36 'operator' => 'or',
37 ],
38 [
39 'value' => '',
40 'attribute' => 'show_table_header',
41 'operator' => 'or',
42 ],
43 ];
44
45 return [
46 'id' => uniqid(),
47 'type' => self::$type,
48 'name' => __( 'Order Details', 'yaymail' ),
49 'icon' => self::$icon,
50 'group' => 'woocommerce',
51 'available' => true,
52 'position' => 190,
53 'data' => [
54 'rich_text' => [
55 'value_path' => 'rich_text',
56 'component' => '',
57 'title' => __( 'Content', 'yaymail' ),
58 'default_value' => $attributes['rich_text'] ?? '[yaymail_order_details]',
59 'type' => 'content',
60 ],
61 'payment_instructions' => [
62 'value_path' => 'payment_instructions',
63 'component' => '',
64 'title' => __( 'Payment instructions', 'yaymail' ),
65 'default_value' => '[yaymail_payment_instructions]',
66 'type' => 'content',
67 ],
68 'container_group_definition' => [
69 'component' => 'GroupDefinition',
70 'title' => __( 'Container settings', 'yaymail' ),
71 'description' => __( 'Handle container layout settings', 'yaymail' ),
72 ],
73 'padding' => [
74 'value_path' => 'padding',
75 'component' => 'Spacing',
76 'title' => __( 'Padding', 'yaymail' ),
77 'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [
78 'top' => '15',
79 'right' => '50',
80 'bottom' => '15',
81 'left' => '50',
82 ],
83 'type' => 'style',
84 ],
85 'background_color' => [
86 'value_path' => 'background_color',
87 'component' => 'Color',
88 'title' => __( 'Background color', 'yaymail' ),
89 'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff',
90 'type' => 'style',
91 ],
92 'border' => [
93 'value_path' => 'border',
94 'component' => 'Border',
95 'title' => __( 'Border', 'yaymail' ),
96 'default_value' => isset( $attributes['border'] ) ? $attributes['border'] : AttributesData::BORDER_DEFAULT,
97 'type' => 'style',
98 ],
99 'table_setting_breaker' => [
100 'component' => 'LineBreaker',
101 ],
102 'table_group_definition' => [
103 'component' => 'GroupDefinition',
104 'title' => __( 'Table settings', 'yaymail' ),
105 'description' => __( 'Handle table settings', 'yaymail' ),
106 ],
107 'layout_type' => [
108 'value_path' => 'layout_type',
109 'component' => 'Selector',
110 'title' => __( 'Layout type', 'yaymail' ),
111 'default_value' => isset( $attributes['layout_type'] ) ? $attributes['layout_type'] : $layout_type,
112 'options' => [
113 [
114 'label' => __( 'Legacy', 'yaymail' ),
115 'value' => 'legacy',
116 ],
117 [
118 'label' => __( 'Modern', 'yaymail' ),
119 'value' => 'modern',
120 ],
121 ],
122 'type' => 'content',
123 ],
124 'title' => [
125 'value_path' => 'title',
126 'component' => 'RichTextEditor',
127 'title' => __( 'Title', 'yaymail' ),
128 'default_value' => isset( $attributes['title'] ) ? $attributes['title'] : '<span style="font-size: 20px;">Order #[yaymail_order_number] <b>([yaymail_order_date])</b></span>',
129 'text_color_path' => 'title_color',
130 'background_color_path' => 'background_color',
131 'type' => 'content',
132 ],
133 'title_color' => [
134 'value_path' => 'title_color',
135 'component' => 'Color',
136 'title' => __( 'Title color', 'yaymail' ),
137 'default_value' => isset( $attributes['title_color'] ) ? $attributes['title_color'] : YAYMAIL_COLOR_WC_DEFAULT,
138 'type' => 'style',
139 ],
140 'text_color' => [
141 'value_path' => 'text_color',
142 'component' => 'Color',
143 'title' => __( 'Text color', 'yaymail' ),
144 'default_value' => isset( $attributes['text_color'] ) ? $attributes['text_color'] : YAYMAIL_COLOR_TEXT_DEFAULT,
145 'type' => 'style',
146 ],
147 'border_color' => [
148 'value_path' => 'border_color',
149 'component' => 'Color',
150 'title' => __( 'Border color', 'yaymail' ),
151 'default_value' => isset( $attributes['border_color'] ) ? $attributes['border_color'] : YAYMAIL_COLOR_BORDER_DEFAULT,
152 'type' => 'style',
153 ],
154 'font_family' => [
155 'value_path' => 'font_family',
156 'component' => 'FontFamilySelector',
157 'title' => __( 'Font family', 'yaymail' ),
158 'default_value' => isset( $attributes['font_family'] ) ? $attributes['font_family'] : YAYMAIL_DEFAULT_FAMILY,
159 'type' => 'style',
160 ],
161 'table_content_font_size' => [
162 'value_path' => 'table_content_font_size',
163 'component' => 'Dimension',
164 'title' => __( 'Table content font size', 'yaymail' ),
165 'default_value' => isset( $attributes['table_content_font_size'] ) ? $attributes['table_content_font_size'] : '14',
166 'type' => 'style',
167 'min' => 8,
168 'max' => 25,
169 'unit' => 'px',
170 ],
171 'table_heading_line_breaker' => [
172 'component' => 'LineBreaker',
173 ],
174 'table_heading_group_definition' => [
175 'component' => 'GroupDefinition',
176 'title' => __( 'Table heading settings', 'yaymail' ),
177 'description' => __( 'Handle table heading settings', 'yaymail' ),
178 ],
179 'table_heading_font_size' => [
180 'value_path' => 'table_heading_font_size',
181 'component' => 'Dimension',
182 'title' => __( 'Table heading font size', 'yaymail' ),
183 'default_value' => isset( $attributes['table_heading_font_size'] ) ? $attributes['table_heading_font_size'] : '14',
184 'type' => 'style',
185 'min' => 8,
186 'max' => 25,
187 'unit' => 'px',
188 ],
189 'show_table_header' => [
190 'value_path' => 'show_table_header',
191 'component' => 'Switcher',
192 'title' => __( 'Show table header', 'yaymail' ),
193 'default_value' => isset( $attributes['show_table_header'] ) ? $attributes['show_table_header'] : true,
194 'type' => 'content',
195 ],
196 'product_title' => [
197 'value_path' => 'product_title',
198 'component' => 'TextInput',
199 'title' => __( 'Product', 'yaymail' ),
200 'default_value' => esc_html__( 'Product', 'woocommerce' ),
201 'type' => 'content',
202 'conditions' => $title_conditions,
203 ],
204 'cost_title' => [
205 'value_path' => 'cost_title',
206 'component' => 'TextInput',
207 'title' => __( 'Cost', 'yaymail' ),
208 'default_value' => esc_html__( 'Cost', 'woocommerce' ),
209 'type' => 'content',
210 'conditions' => $title_conditions,
211 ],
212 'quantity_title' => [
213 'value_path' => 'quantity_title',
214 'component' => 'TextInput',
215 'title' => __( 'Quantity', 'yaymail' ),
216 'default_value' => esc_html__( 'Quantity', 'woocommerce' ),
217 'type' => 'content',
218 'conditions' => $title_conditions,
219 ],
220 'price_title' => [
221 'value_path' => 'price_title',
222 'component' => 'TextInput',
223 'title' => __( 'Price', 'yaymail' ),
224 'default_value' => esc_html__( 'Price', 'woocommerce' ),
225 'type' => 'content',
226 'conditions' => $title_conditions,
227 ],
228 'cart_subtotal_title' => [
229 'value_path' => 'cart_subtotal_title',
230 'component' => 'TextInput',
231 'title' => __( 'Subtotal', 'yaymail' ),
232 'default_value' => esc_html__( 'Subtotal:', 'woocommerce' ),
233 'type' => 'content',
234 ],
235 'payment_method_title' => [
236 'value_path' => 'payment_method_title',
237 'component' => 'TextInput',
238 'title' => __( 'Payment method', 'yaymail' ),
239 'default_value' => esc_html__( 'Payment method:', 'woocommerce' ),
240 'type' => 'content',
241 ],
242 'order_total_title' => [
243 'value_path' => 'order_total_title',
244 'component' => 'TextInput',
245 'title' => __( 'Total', 'yaymail' ),
246 'default_value' => esc_html__( 'Total:', 'woocommerce' ),
247 'type' => 'content',
248 ],
249 'order_note_title' => [
250 'value_path' => 'order_note_title',
251 'component' => 'TextInput',
252 'title' => __( 'Note', 'yaymail' ),
253 'default_value' => esc_html__( 'Note:', 'woocommerce' ),
254 'type' => 'content',
255 ],
256 'shipping_title' => [
257 'value_path' => 'shipping_title',
258 'component' => 'TextInput',
259 'title' => __( 'Shipping', 'yaymail' ),
260 'default_value' => esc_html__( 'Shipping:', 'woocommerce' ) . ' [yaymail_shipping_method]',
261 'type' => 'content',
262 ],
263 'discount_title' => [
264 'value_path' => 'discount_title',
265 'component' => 'TextInput',
266 'title' => __( 'Discount', 'yaymail' ),
267 'default_value' => esc_html__( 'Discount:', 'woocommerce' ),
268 'type' => 'content',
269 ],
270 'custom_footer_rows_breaker' => [
271 'component' => 'LineBreaker',
272 ],
273 'custom_footer_rows_group' => [
274 'component' => 'GroupDefinition',
275 'title' => __( 'Custom Footer Rows', 'yaymail' ),
276 'description' => __( 'Add custom rows to the order totals footer', 'yaymail' ),
277 ],
278 'custom_footer_rows' => [
279 'value_path' => 'custom_footer_rows',
280 'component' => 'CustomFooterRowsEditor',
281 'title' => __( 'Custom Footer Rows', 'yaymail' ),
282 'default_value' => isset( $attributes['custom_footer_rows'] ) ? $attributes['custom_footer_rows'] : [],
283 'type' => 'content',
284 ],
285 ],
286 ];
287 }
288 }
289