PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.2
YayMail – WooCommerce Email Customizer v4.3.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 / OrderDetailsDownload.php

OrderDetailsDownload.php in YayMail – WooCommerce Email Customizer 4.3.2, at src/Elements/OrderDetailsDownload.php

199 lines 10.1 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\Utils\SingletonTrait;
6 use YayMail\Emails\CustomerCompletedOrder;
7 use YayMail\Emails\CustomerProcessingOrder;
8 use YayMail\Constants\AttributesData;
9
10 /**
11 * OrderDetailsDownload Elements
12 */
13 class OrderDetailsDownload extends BaseElement {
14
15 use SingletonTrait;
16
17 protected static $type = 'order_details_download';
18
19 protected function __construct() {
20 $this->available_email_ids = [
21 CustomerCompletedOrder::get_instance()->get_id(),
22 CustomerProcessingOrder::get_instance()->get_id(),
23 ];
24 }
25
26 public static function get_data( $attributes = [] ) {
27 $is_email_improvements_enabled = get_option( 'woocommerce_feature_email_improvements_enabled', 'no' ) === 'yes';
28 $layout_type = $is_email_improvements_enabled ? 'modern' : 'legacy';
29
30 self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20">
31 <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"/>
32 <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"/>
33 <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"/>
34 <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"/>
35 <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"/>
36 <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"/>
37 </svg>';
38
39 return [
40 'id' => uniqid(),
41 'type' => self::$type,
42 'name' => __( 'Order Details Download', 'yaymail' ),
43 'icon' => self::$icon,
44 'group' => 'woocommerce',
45 'available' => true,
46 'position' => 200,
47 'data' => [
48 'rich_text' => [
49 'value_path' => 'rich_text',
50 'component' => '',
51 'title' => __( 'Content', 'yaymail' ),
52 'default_value' => isset( $attributes['rich_text'] ) ? $attributes['rich_text'] : '[yaymail_order_details_download_product]',
53 'type' => 'content',
54 ],
55 'container_group_definition' => [
56 'component' => 'GroupDefinition',
57 'title' => __( 'Container settings', 'yaymail' ),
58 'description' => __( 'Handle container layout settings', 'yaymail' ),
59 ],
60 'padding' => [
61 'value_path' => 'padding',
62 'component' => 'Spacing',
63 'title' => __( 'Padding', 'yaymail' ),
64 'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [
65 'top' => '15',
66 'right' => '50',
67 'bottom' => '15',
68 'left' => '50',
69 ],
70 'type' => 'style',
71 ],
72 'background_color' => [
73 'value_path' => 'background_color',
74 'component' => 'Color',
75 'title' => __( 'Background color', 'yaymail' ),
76 'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff',
77 'type' => 'style',
78 ],
79 'border' => [
80 'value_path' => 'border',
81 'component' => 'Border',
82 'title' => __( 'Border', 'yaymail' ),
83 'default_value' => isset( $attributes['border'] ) ? $attributes['border'] : AttributesData::BORDER_DEFAULT,
84 'type' => 'style',
85 ],
86 'table_setting_breaker' => [
87 'component' => 'LineBreaker',
88 ],
89 'table_group_definition' => [
90 'component' => 'GroupDefinition',
91 'title' => __( 'Table settings', 'yaymail' ),
92 'description' => __( 'Handle table settings', 'yaymail' ),
93 ],
94 'layout_type' => [
95 'value_path' => 'layout_type',
96 'component' => 'Selector',
97 'title' => __( 'Layout type', 'yaymail' ),
98 'default_value' => isset( $attributes['layout_type'] ) ? $attributes['layout_type'] : $layout_type,
99 'options' => [
100 [
101 'label' => __( 'Legacy', 'yaymail' ),
102 'value' => 'legacy',
103 ],
104 [
105 'label' => __( 'Modern', 'yaymail' ),
106 'value' => 'modern',
107 ],
108 ],
109 'type' => 'content',
110 ],
111 'title' => [
112 'value_path' => 'title',
113 'component' => 'RichTextEditor',
114 'title' => __( 'Title', 'yaymail' ),
115 'default_value' => isset( $attributes['title'] ) ? $attributes['title'] : '<span style="font-size: 20px;font-weight:600;">Downloads</span>',
116 'type' => 'content',
117 ],
118 'title_color' => [
119 'value_path' => 'title_color',
120 'component' => 'Color',
121 'title' => __( 'Title color', 'yaymail' ),
122 'default_value' => isset( $attributes['title_color'] ) ? $attributes['title_color'] : YAYMAIL_COLOR_WC_DEFAULT,
123 'type' => 'style',
124 ],
125 'text_color' => [
126 'value_path' => 'text_color',
127 'component' => 'Color',
128 'title' => __( 'Text color', 'yaymail' ),
129 'default_value' => isset( $attributes['text_color'] ) ? $attributes['text_color'] : YAYMAIL_COLOR_TEXT_DEFAULT,
130 'type' => 'style',
131 ],
132 'border_color' => [
133 'value_path' => 'border_color',
134 'component' => 'Color',
135 'title' => __( 'Border color', 'yaymail' ),
136 'default_value' => isset( $attributes['border_color'] ) ? $attributes['border_color'] : YAYMAIL_COLOR_BORDER_DEFAULT,
137 'type' => 'style',
138 ],
139 'font_family' => [
140 'value_path' => 'font_family',
141 'component' => 'FontFamilySelector',
142 'title' => __( 'Font family', 'yaymail' ),
143 'default_value' => isset( $attributes['font_family'] ) ? $attributes['font_family'] : YAYMAIL_DEFAULT_FAMILY,
144 'type' => 'style',
145 ],
146 'table_content_font_size' => [
147 'value_path' => 'table_content_font_size',
148 'component' => 'Dimension',
149 'title' => __( 'Table content font size', 'yaymail' ),
150 'default_value' => isset( $attributes['table_content_font_size'] ) ? $attributes['table_content_font_size'] : '14',
151 'type' => 'style',
152 'min' => 8,
153 'max' => 25,
154 'unit' => 'px',
155 ],
156 'table_heading_line_breaker' => [
157 'component' => 'LineBreaker',
158 ],
159 'table_heading_group_definition' => [
160 'component' => 'GroupDefinition',
161 'title' => __( 'Table heading settings', 'yaymail' ),
162 'description' => __( 'Handle table heading settings', 'yaymail' ),
163 ],
164 'table_heading_font_size' => [
165 'value_path' => 'table_heading_font_size',
166 'component' => 'Dimension',
167 'title' => __( 'Table heading font size', 'yaymail' ),
168 'default_value' => isset( $attributes['table_heading_font_size'] ) ? $attributes['table_heading_font_size'] : '14',
169 'type' => 'style',
170 'min' => 8,
171 'max' => 25,
172 'unit' => 'px',
173 ],
174 'product_title' => [
175 'value_path' => 'product_title',
176 'component' => 'TextInput',
177 'title' => __( 'Product', 'yaymail' ),
178 'default_value' => esc_html__( 'Product', 'woocommerce' ),
179 'type' => 'content',
180 ],
181 'expires_title' => [
182 'value_path' => 'expires_title',
183 'component' => 'TextInput',
184 'title' => __( 'Expires', 'yaymail' ),
185 'default_value' => esc_html__( 'Expires', 'woocommerce' ),
186 'type' => 'content',
187 ],
188 'download_title' => [
189 'value_path' => 'download_title',
190 'component' => 'TextInput',
191 'title' => __( 'Download', 'yaymail' ),
192 'default_value' => esc_html__( 'Download', 'woocommerce' ),
193 'type' => 'content',
194 ],
195 ],
196 ];
197 }
198 }
199