PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.3
YayMail – WooCommerce Email Customizer v4.3.3
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 / FeaturedProducts.php

FeaturedProducts.php in YayMail – WooCommerce Email Customizer 4.3.3, at src/Elements/FeaturedProducts.php

350 lines 24.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
7 /**
8 * Featured Products Elements
9 */
10 class FeaturedProducts extends BaseElement {
11
12 use SingletonTrait;
13
14 protected static $type = 'featured_products';
15
16 public $available_email_ids = [];
17
18 public static function get_data( $attributes = [] ) {
19 self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20">
20 <g>
21 <path d="M7.7,2.7v9.75H2.5V2.7h5.2M8.7,1.2H1.5c-.28,0-.5.22-.5.5v11.75c0,.28.22.5.5.5h7.2c.28,0,.5-.22.5-.5V1.7c0-.28-.22-.5-.5-.5h0Z"/>
22 <g>
23 <path d="M8,16.49H2.21c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h5.79c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
24 <path d="M7.19,18.95H3.01c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h4.19c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
25 </g>
26 </g>
27 <g>
28 <path d="M17.5,2.7v9.75h-5.2V2.7h5.2M18.5,1.2h-7.2c-.28,0-.5.22-.5.5v11.75c0,.28.22.5.5.5h7.2c.28,0,.5-.22.5-.5V1.7c0-.28-.22-.5-.5-.5h0Z"/>
29 <path d="M17.79,16.49h-5.79c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h5.79c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
30 <path d="M16.99,18.95h-4.19c-.41,0-.75-.34-.75-.75s.34-.75.75-.75h4.19c.41,0,.75.34.75.75s-.34.75-.75.75Z"/>
31 </g>
32 </svg>';
33
34 $buy_button_conditions = [
35 [
36 'comparison' => 'contain',
37 'value' => [ 'buy_button' ],
38 'attribute' => 'showing_items',
39 ],
40 ];
41
42 $pro_preview = '';
43
44 return [
45 'id' => uniqid(),
46 'type' => self::$type,
47 'name' => __( 'Featured Products', 'yaymail' ),
48 'icon' => self::$icon,
49 'group' => 'block',
50 'available' => false,
51 'disabled_reason' => [
52 'html' => '<svg id="yaymail-featured_products" class="yaymail-element-disabled-icon" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 428 300"><defs><style> #yaymail-featured_products .st0 { fill: #fff; } #yaymail-featured_products .st1 { fill: #edeff3; } #yaymail-featured_products .st2 { fill: none; } #yaymail-featured_products .st3 { fill: #1f2937; } #yaymail-featured_products .st4 { fill: #dee2e9; } #yaymail-featured_products .st5 { fill: #c9ced6; } </style></defs><g id="Layer_1-2"><g><rect class="st0" width="428" height="300"/><g><path class="st3" d="M101.3,31.8h12.7v2.9h-9.2v5.1h8.7v2.9h-8.7v7.8h-3.4v-18.7h0Z"/><path class="st3" d="M119.1,44.2c0,2.1,1.1,3.9,3.1,3.9s2.3-.8,2.7-1.7h3.4c-.5,1.7-2,4.4-6.2,4.4s-6.4-3.5-6.4-7.1,2.2-7.5,6.6-7.5,6.2,3.5,6.2,6.8,0,.8,0,1.2h-9.4,0ZM125.1,42.1c0-1.8-.8-3.4-2.9-3.4s-2.9,1.4-3.1,3.4h6Z"/><path class="st3" d="M142.4,47.1c0,1.3.1,3,.2,3.4h-3.2c-.1-.3-.2-1-.2-1.5-.5.8-1.5,1.8-4,1.8s-4.7-2.2-4.7-4.3c0-3.1,2.5-4.6,6.6-4.6h2.1v-1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4.6h0Z"/><path class="st3" d="M218.4,31.8h7.5c3.9,0,6.5,2.2,6.5,5.7s-2.9,5.8-6.6,5.8h-3.9v7.2h-3.5v-18.7h0ZM221.9,40.5h3.5c2.1,0,3.4-.9,3.4-2.9s-1.4-2.9-3.3-2.9h-3.6v5.8h0Z"/><path class="st3" d="M234.9,40.4c0-1.6,0-2.8,0-3.8h3.3c0,.3,0,1.6,0,2.6.6-1.7,2.2-2.9,4.5-2.9v3.2c-2.8,0-4.5,1-4.5,4.7v6.3h-3.4v-10.1h0Z"/><path class="st3" d="M257.5,43.5c0,4.1-2.4,7.3-6.8,7.3s-6.7-3.1-6.7-7.2,2.5-7.3,6.8-7.3,6.6,2.9,6.6,7.2ZM247.5,43.5c0,2.8,1.3,4.6,3.3,4.6s3.3-1.8,3.3-4.6-1.2-4.6-3.3-4.6-3.3,1.6-3.3,4.6Z"/><path class="st3" d="M272.8,30.7v15.9c0,1.3,0,2.6,0,3.8h-3.2c0-.4-.1-1.2-.2-1.6-.7,1.2-1.9,2-4.1,2-3.5,0-5.8-2.8-5.8-7.1s2.4-7.4,6.3-7.4,3.2.8,3.6,1.5v-7h3.4ZM263.1,43.6c0,2.9,1.2,4.5,3.2,4.5,2.8,0,3.3-2.3,3.3-4.6s-.4-4.5-3.2-4.5-3.4,1.7-3.4,4.6Z"/><path class="st3" d="M288.3,46.5c0,1.3,0,2.9,0,4h-3.3c0-.4,0-1.2-.1-1.8-.8,1.4-2,2.1-4,2.1s-4.6-1.5-4.6-5.1v-9.1h3.4v8.4c0,1.6.5,3,2.4,3s2.8-1.1,2.8-4.1v-7.3h3.4v9.8h0Z"/><path class="st3" d="M303.7,46.1c-.5,2.3-2.1,4.7-6.1,4.7s-6.4-2.9-6.4-7.2,2.4-7.3,6.6-7.3,5.8,3.2,5.9,4.8h-3.3c-.3-1.2-1-2.2-2.7-2.2s-3.1,1.7-3.1,4.6,1.1,4.6,3.1,4.6,2.3-.8,2.7-2.1h3.3Z"/><path class="st3" d="M305,36.6h2.2v-3.9h3.4v3.9h2.8v2.6h-2.8v7.3c0,1.2.3,1.7,1.5,1.7s.7,0,1,0v2.4c-.7.2-1.7.3-2.4.3-2.5,0-3.4-1.3-3.4-3.7v-7.8h-2.2v-2.6h0Z"/><path class="st3" d="M318.2,46.4c.3,1.2,1.3,2,2.9,2s2.2-.6,2.2-1.6-.6-1.5-2.8-2c-4.3-1.1-5.1-2.4-5.1-4.3s1.4-4.1,5.4-4.1,5.4,2.2,5.6,4.1h-3.2c-.1-.6-.6-1.7-2.5-1.7s-2,.7-2,1.4.5,1.2,2.8,1.8c4.5,1,5.2,2.6,5.2,4.6s-1.8,4.3-5.8,4.3-5.8-2-6.1-4.4h3.3,0Z"/></g><rect class="st4" x="76.1" y="75.1" width="275.8" height="13.6" rx="6.8" ry="6.8"/><g><path class="st1" d="M41,197.3h80.7c2.6,0,4.8,2.1,4.8,4.8h0c0,2.6-2.1,4.8-4.8,4.8H41c-2.6,0-4.8-2.1-4.8-4.8h0c0-2.6,2.1-4.8,4.8-4.8Z"/><path class="st1" d="M52.2,215.9h58.2c2.6,0,4.8,2.1,4.8,4.8h0c0,2.6-2.1,4.8-4.8,4.8h-58.2c-2.6,0-4.8-2.1-4.8-4.8h0c0-2.6,2.1-4.8,4.8-4.8Z"/></g><rect class="st1" x="31.5" y="108.1" width="99.7" height="76" rx="7" ry="7"/><g><rect class="st4" x="43.4" y="240.1" width="75.9" height="28.1" rx="4" ry="4"/><path class="st2" d="M85,258.8c.9,0,1.7.8,1.7,1.7s-.8,1.7-1.7,1.7-1.7-.8-1.7-1.7.8-1.7,1.7-1.7ZM78.1,258.8c.9,0,1.7.8,1.7,1.7s-.8,1.7-1.7,1.7-1.7-.8-1.7-1.7.8-1.7,1.7-1.7ZM89.5,250c-.3-.5-.9-.8-1.4-.8h-10.9v-2.2c0-.5-.4-.9-.9-.9h-2.6c-.5,0-.9.4-.9.9s.4.9.9.9h1.7v3.5h0v4.4c0,1,.8,1.7,1.7,1.7h9c.7,0,1.3-.4,1.6-1.1l1.9-4.8c.2-.5.2-1.1-.2-1.6h0Z"/></g><g><path class="st1" d="M173.4,197.3h80.7c2.6,0,4.8,2.1,4.8,4.8h0c0,2.6-2.1,4.8-4.8,4.8h-80.7c-2.6,0-4.8-2.1-4.8-4.8h0c0-2.6,2.1-4.8,4.8-4.8Z"/><path class="st1" d="M184.6,215.9h58.2c2.6,0,4.8,2.1,4.8,4.8h0c0,2.6-2.1,4.8-4.8,4.8h-58.2c-2.6,0-4.8-2.1-4.8-4.8h0c0-2.6,2.1-4.8,4.8-4.8Z"/></g><rect class="st1" x="163.9" y="108.1" width="99.7" height="76" rx="7" ry="7"/><g><rect class="st4" x="175.8" y="240.1" width="75.9" height="28.1" rx="4" ry="4"/><path class="st2" d="M217.4,258.8c.9,0,1.7.8,1.7,1.7s-.8,1.7-1.7,1.7-1.7-.8-1.7-1.7.8-1.7,1.7-1.7ZM210.5,258.8c.9,0,1.7.8,1.7,1.7s-.8,1.7-1.7,1.7-1.7-.8-1.7-1.7.8-1.7,1.7-1.7ZM221.9,250c-.3-.5-.9-.8-1.4-.8h-10.9v-2.2c0-.5-.4-.9-.9-.9h-2.6c-.5,0-.9.4-.9.9s.4.9.9.9h1.7v3.5h0v4.4c0,1,.8,1.7,1.7,1.7h9c.7,0,1.4-.4,1.6-1.1l1.9-4.8c.2-.5.1-1.1-.2-1.6h0Z"/></g><g><path class="st1" d="M306.3,197.3h80.7c2.6,0,4.8,2.1,4.8,4.8h0c0,2.6-2.1,4.8-4.8,4.8h-80.7c-2.6,0-4.8-2.1-4.8-4.8h0c0-2.6,2.1-4.8,4.8-4.8Z"/><path class="st1" d="M317.6,215.9h58.2c2.6,0,4.8,2.1,4.8,4.8h0c0,2.6-2.1,4.8-4.8,4.8h-58.2c-2.6,0-4.8-2.1-4.8-4.8h0c0-2.6,2.1-4.8,4.8-4.8Z"/></g><rect class="st1" x="296.8" y="108.1" width="99.7" height="76" rx="7" ry="7"/><g><rect class="st4" x="308.7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8,4.6,0,.7-.9,1.3-1.7,1.9-2.6,2.5-3.5,5-7,7.6-10.4.9-1.2,1.9-1.5,3.1-1,.6.3,1,.8,1.4,1.4,5.1,7.1,10.3,14.2,15.4,21.3.5.7,1.3,1.5.8,2.5-.5,1.1-1.6.8-2.5.8h0Z"/><path class="st5" d="M338.5,139.5c-2.8,0-5.1-2.4-5.1-5.2,0-2.8,2.4-5.1,5.1-5.1,2.8,0,5.2,2.4,5.1,5.2,0,2.8-2.4,5.1-5.2,5.1h0ZM369.6,162.9c-7.6,0-15.2,0-22.9,0h-23.6c-.7,0-1.5,0-1.8-.7-.4-.7,0-1.4.4-2,3-4.2,6-8.4,9.1-12.5,1.3-1.8,2.9-1.7,4.3,0,.8,1.1,1.6,2.2,2.4,3.3,1.4,1.8,3.2,1.8,4.6,0,.7-.9,1.3-1.7,1.9-2.6,2.5-3.5,5-7,7.6-10.4.9-1.2,1.9-1.5,3-1,.6.3,1,.8,1.4,1.4,5.1,7.1,10.3,14.2,15.4,21.3.5.7,1.3,1.5.8,2.5-.5,1.1-1.6.8-2.5.8h0Z"/></g></g></svg>'
53 . '<span>'
54 . __( 'This element is available in YayMail Pro', 'yaymail' )
55 . '</span>',
56 ],
57 'position' => 220,
58 'data' => [
59 'padding' => [
60 'value_path' => 'padding',
61 'component' => 'Spacing',
62 'title' => __( 'Padding', 'yaymail' ),
63 'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [
64 'top' => '15',
65 'right' => '50',
66 'bottom' => '15',
67 'left' => '50',
68 ],
69 'type' => 'style',
70 ],
71 'background_color' => [
72 'value_path' => 'background_color',
73 'component' => 'Color',
74 'title' => __( 'Background color', 'yaymail' ),
75 'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff',
76 'type' => 'style',
77 ],
78 'text_color' => [
79 'value_path' => 'text_color',
80 'component' => 'Color',
81 'title' => __( 'Text color', 'yaymail' ),
82 'default_value' => isset( $attributes['text_color'] ) ? $attributes['text_color'] : YAYMAIL_COLOR_TEXT_DEFAULT,
83 'type' => 'style',
84 ],
85 'font_family' => [
86 'value_path' => 'font_family',
87 'component' => 'FontFamilySelector',
88 'title' => __( 'Font family', 'yaymail' ),
89 'default_value' => isset( $attributes['font_family'] ) ? $attributes['font_family'] : YAYMAIL_DEFAULT_FAMILY,
90 'type' => 'style',
91 ],
92 'content_breaker' => [
93 'component' => 'LineBreaker',
94 ],
95 'content_group_definition' => [
96 'component' => 'GroupDefinition',
97 'title' => __( 'Content', 'yaymail' ),
98 'description' => __( 'Handle block items settings', 'yaymail' ),
99 ],
100 'showing_items' => [
101 'value_path' => 'showing_items',
102 'component' => 'CheckboxGroup',
103 'title' => __( 'Showing items', 'yaymail' ),
104 'default_value' => isset( $attributes['showing_items'] ) ? $attributes['showing_items'] : [ 'top_content', 'product_image', 'product_name', 'product_price', 'product_original_price', 'buy_button' ],
105 'type' => 'content',
106 'options' => [
107 [
108 'label' => __( 'Top content', 'yaymail' ),
109 'value' => 'top_content',
110 ],
111 [
112 'label' => __( 'Product image', 'yaymail' ),
113 'value' => 'product_image',
114 ],
115 [
116 'label' => __( 'Product name', 'yaymail' ),
117 'value' => 'product_name',
118 ],
119 [
120 'label' => __( 'Product price', 'yaymail' ),
121 'value' => 'product_price',
122 ],
123 [
124 'label' => __( 'Product original price', 'yaymail' ),
125 'value' => 'product_original_price',
126 ],
127 [
128 'label' => __( 'Buy button', 'yaymail' ),
129 'value' => 'buy_button',
130 ],
131 ],
132 ],
133 'top_content' => [
134 'value_path' => 'top_content',
135 'component' => 'RichTextEditor',
136 'title' => __( 'Top content', 'yaymail' ),
137 'default_value' => isset( $attributes['top_content'] ) ? $attributes['top_content'] : '<p style="text-align: center;"><span style="font-size: 18px;"><strong>FEATURED PRODUCTS</strong></span></p>
138 <p style="font-size: 14px; text-align: center;">&nbsp;</p>
139 <p style="text-align: center;">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>',
140 'type' => 'content',
141 ],
142 'sale_price_color' => [
143 'value_path' => 'sale_price_color',
144 'component' => 'Color',
145 'title' => __( 'Product price color', 'yaymail' ),
146 'default_value' => isset( $attributes['sale_price_color'] ) ? $attributes['sale_price_color'] : '#ec4770',
147 'type' => 'style',
148 'conditions' => [
149 [
150 'comparison' => 'contain',
151 'value' => [ 'product_price' ],
152 'attribute' => 'showing_items',
153 ],
154 ],
155 ],
156 'regular_price_color' => [
157 'value_path' => 'regular_price_color',
158 'component' => 'Color',
159 'title' => __( 'Product original price color', 'yaymail' ),
160 'default_value' => isset( $attributes['regular_price_color'] ) ? $attributes['regular_price_color'] : '#808080',
161 'type' => 'style',
162 'conditions' => [
163 [
164 'comparison' => 'contain',
165 'value' => [ 'product_original_price' ],
166 'attribute' => 'showing_items',
167 ],
168 ],
169 ],
170 'button_breaker' => [
171 'component' => 'LineBreaker',
172 'conditions' => $buy_button_conditions,
173 ],
174 'button_group_definition' => [
175 'component' => 'GroupDefinition',
176 'title' => __( 'Button', 'yaymail' ),
177 'description' => __( 'Handle buy button settings', 'yaymail' ),
178 'conditions' => $buy_button_conditions,
179 ],
180 'buy_button_label' => [
181 'value_path' => 'buy_button_label',
182 'component' => 'TextInput',
183 'title' => __( 'Buy button text', 'yaymail' ),
184 'default_value' => isset( $attributes['buy_button_label'] ) ? $attributes['buy_button_label'] : __( 'BUY NOW', 'yaymail' ),
185 'type' => 'content',
186 'conditions' => $buy_button_conditions,
187 ],
188 'buy_button_background_color' => [
189 'value_path' => 'buy_button_background_color',
190 'component' => 'Color',
191 'title' => __( 'Buy button background color', 'yaymail' ),
192 'default_value' => isset( $attributes['buy_button_background_color'] ) ? $attributes['buy_button_background_color'] : '#ec4770',
193 'type' => 'style',
194 'conditions' => $buy_button_conditions,
195 ],
196 'buy_button_text_color' => [
197 'value_path' => 'buy_button_text_color',
198 'component' => 'Color',
199 'title' => __( 'Buy button text color', 'yaymail' ),
200 'default_value' => isset( $attributes['buy_button_text_color'] ) ? $attributes['buy_button_text_color'] : '#ffffff',
201 'type' => 'style',
202 'conditions' => $buy_button_conditions,
203 ],
204 'products_breaker' => [
205 'component' => 'LineBreaker',
206 ],
207 'products_group_definition' => [
208 'component' => 'GroupDefinition',
209 'title' => __( 'Products', 'yaymail' ),
210 'description' => __( 'Handle products settings', 'yaymail' ),
211 ],
212 'products_per_row' => [
213 'value_path' => 'products_per_row',
214 'component' => 'NumberInput',
215 'title' => __( 'Products per row', 'yaymail' ),
216 'default_value' => isset( $attributes['products_per_row'] ) ? $attributes['products_per_row'] : '3',
217 'min' => 1,
218 'max' => 3,
219 'type' => 'content',
220 ],
221 'product_type' => [
222 'value_path' => 'product_type',
223 'component' => 'Selector',
224 'title' => __( 'Product type', 'yaymail' ),
225 'default_value' => isset( $attributes['product_type'] ) ? $attributes['product_type'] : 'newest',
226 'type' => 'content',
227 'options' => [
228 [
229 'label' => __( 'Newest', 'yaymail' ),
230 'value' => 'newest',
231 ],
232 [
233 'label' => __( 'On sale', 'yaymail' ),
234 'value' => 'on_sale',
235 ],
236 [
237 'label' => __( 'Featured', 'yaymail' ),
238 'value' => 'featured',
239 ],
240 [
241 'label' => __( 'Category selections', 'yaymail' ),
242 'value' => 'category_selections',
243 ],
244 [
245 'label' => __( 'Tag selections', 'yaymail' ),
246 'value' => 'tag_selections',
247 ],
248 [
249 'label' => __( 'Product selections', 'yaymail' ),
250 'value' => 'product_selections',
251 ],
252 ],
253 ],
254 'categories' => [
255 'value_path' => 'categories',
256 'component' => 'EntitiesSelector',
257 'title' => __( 'Product categories', 'yaymail' ),
258 'default_value' => isset( $attributes['categories'] ) ? $attributes['categories'] : [],
259 'type' => 'content',
260 'entity_type' => 'categories',
261 'conditions' => [
262 [
263 'value' => 'category_selections',
264 'attribute' => 'product_type',
265 ],
266 ],
267 ],
268 'tags' => [
269 'value_path' => 'tags',
270 'component' => 'EntitiesSelector',
271 'title' => __( 'Product tags', 'yaymail' ),
272 'default_value' => isset( $attributes['tags'] ) ? $attributes['tags'] : [],
273 'type' => 'content',
274 'entity_type' => 'tags',
275 'conditions' => [
276 [
277 'value' => 'tag_selections',
278 'attribute' => 'product_type',
279 ],
280 ],
281 ],
282 'products' => [
283 'value_path' => 'products',
284 'component' => 'EntitiesSelector',
285 'title' => __( 'Products', 'yaymail' ),
286 'default_value' => isset( $attributes['products'] ) ? $attributes['products'] : [],
287 'type' => 'content',
288 'entity_type' => 'products',
289 'conditions' => [
290 [
291 'value' => 'product_selections',
292 'attribute' => 'product_type',
293 ],
294 ],
295 ],
296 'sorted_by' => [
297 'value_path' => 'sorted_by',
298 'component' => 'Selector',
299 'title' => __( 'Sorted by', 'yaymail' ),
300 'default_value' => isset( $attributes['sorted_by'] ) ? $attributes['sorted_by'] : 'none',
301 'options' => [
302 [
303 'label' => __( 'None', 'yaymail' ),
304 'value' => 'none',
305 ],
306 [
307 'label' => __( 'Name A-Z', 'yaymail' ),
308 'value' => 'name_a_z',
309 ],
310 [
311 'label' => __( 'Name Z-A', 'yaymail' ),
312 'value' => 'name_z_a',
313 ],
314 [
315 'label' => __( 'Ascending Price', 'yaymail' ),
316 'value' => 'price_ascending',
317 ],
318 [
319 'label' => __( 'Descending Price', 'yaymail' ),
320 'value' => 'price_descending',
321 ],
322 [
323 'label' => __( 'Random', 'yaymail' ),
324 'value' => 'random',
325 ],
326 ],
327 'type' => 'content',
328 ],
329 'number_of_products' => [
330 'value_path' => 'number_of_products',
331 'component' => 'NumberInput',
332 'title' => __( 'Number of featured products', 'yaymail' ),
333 'default_value' => isset( $attributes['number_of_products'] ) ? $attributes['number_of_products'] : '5',
334 'type' => 'content',
335 'min' => 1,
336 'max' => 20,
337 'is_debounce' => true,
338 'conditions' => [
339 [
340 'comparison' => '!=',
341 'value' => 'product_selections',
342 'attribute' => 'product_type',
343 ],
344 ],
345 ],
346 ],
347 ];
348 }
349 }
350