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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Internal / Features / ProductBlockEditor / ProductTemplates / ProductVariationTemplate.php
woocommerce / src / Internal / Features / ProductBlockEditor / ProductTemplates Last commit date
AbstractProductFormTemplate.php 2 years ago DownloadableProductTrait.php 2 years ago Group.php 1 year ago ProductBlock.php 2 years ago ProductVariationTemplate.php 1 month ago Section.php 1 year ago SimpleProductTemplate.php 1 month ago Subsection.php 1 year ago
ProductVariationTemplate.php
488 lines
1 <?php
2 /**
3 * ProductVariationTemplate
4 */
5
6 namespace Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates;
7
8 use Automattic\WooCommerce\Admin\Features\Features;
9 use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface;
10 use Automattic\WooCommerce\Enums\ProductStockStatus;
11
12 /**
13 * Product Variation Template.
14 */
15 class ProductVariationTemplate extends AbstractProductFormTemplate implements ProductFormTemplateInterface {
16 use DownloadableProductTrait;
17
18 /**
19 * The context name used to identify the editor.
20 */
21 const GROUP_IDS = array(
22 'GENERAL' => 'general',
23 'PRICING' => 'pricing',
24 'INVENTORY' => 'inventory',
25 'SHIPPING' => 'shipping',
26 );
27
28 /**
29 * The option name used check whether the single variation notice has been dismissed.
30 */
31 const SINGLE_VARIATION_NOTICE_DISMISSED_OPTION = 'woocommerce_single_variation_notice_dismissed';
32
33 /**
34 * ProductVariationTemplate constructor.
35 */
36 public function __construct() {
37 $this->add_group_blocks();
38 $this->add_general_group_blocks();
39 $this->add_inventory_group_blocks();
40 $this->add_shipping_group_blocks();
41 }
42
43 /**
44 * Get the template ID.
45 */
46 public function get_id(): string {
47 return 'product-variation';
48 }
49
50 /**
51 * Get the template title.
52 */
53 public function get_title(): string {
54 return __( 'Product Variation Template', 'woocommerce' );
55 }
56
57 /**
58 * Get the template description.
59 */
60 public function get_description(): string {
61 return __( 'Template for the product variation form', 'woocommerce' );
62 }
63
64 /**
65 * Adds the group blocks to the template.
66 */
67 protected function add_group_blocks() {
68 $this->add_group(
69 array(
70 'id' => $this::GROUP_IDS['GENERAL'],
71 'order' => 10,
72 'attributes' => array(
73 'title' => __( 'General', 'woocommerce' ),
74 ),
75 )
76 );
77 $this->add_group(
78 array(
79 'id' => $this::GROUP_IDS['INVENTORY'],
80 'order' => 30,
81 'attributes' => array(
82 'title' => __( 'Inventory', 'woocommerce' ),
83 ),
84 )
85 );
86 $this->add_group(
87 array(
88 'id' => $this::GROUP_IDS['SHIPPING'],
89 'order' => 40,
90 'attributes' => array(
91 'title' => __( 'Shipping', 'woocommerce' ),
92 ),
93 )
94 );
95 }
96
97 /**
98 * Adds the general group blocks to the template.
99 */
100 protected function add_general_group_blocks() {
101 $is_calc_taxes_enabled = wc_tax_enabled();
102
103 $general_group = $this->get_group_by_id( $this::GROUP_IDS['GENERAL'] );
104 $general_group->add_block(
105 array(
106 'id' => 'general-single-variation-notice',
107 'blockName' => 'woocommerce/product-single-variation-notice',
108 'order' => 10,
109 'attributes' => array(
110 'content' => __( '<strong>You’re editing details specific to this variation.</strong> Some information, like description and images, will be inherited from the main product, <noticeLink><parentProductName/></noticeLink>.', 'woocommerce' ),
111 'type' => 'info',
112 'isDismissible' => true,
113 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION,
114 ),
115 )
116 );
117 // Basic Details Section.
118 $basic_details = $general_group->add_section(
119 array(
120 'id' => 'product-variation-details-section',
121 'order' => 10,
122 'attributes' => array(
123 'title' => __( 'Variation details', 'woocommerce' ),
124 'description' => __( 'This info will be displayed on the product page, category pages, social media, and search results.', 'woocommerce' ),
125 ),
126 )
127 );
128
129 // Product Pricing columns.
130 $pricing_columns = $basic_details->add_block(
131 array(
132 'id' => 'product-pricing-group-pricing-columns',
133 'blockName' => 'core/columns',
134 'order' => 10,
135 )
136 );
137 $pricing_column_1 = $pricing_columns->add_block(
138 array(
139 'id' => 'product-pricing-group-pricing-column-1',
140 'blockName' => 'core/column',
141 'order' => 10,
142 'attributes' => array(
143 'templateLock' => 'all',
144 ),
145 )
146 );
147 $pricing_column_1->add_block(
148 array(
149 'id' => 'product-pricing-regular-price',
150 'blockName' => 'woocommerce/product-regular-price-field',
151 'order' => 10,
152 'attributes' => array(
153 'name' => 'regular_price',
154 'label' => __( 'Regular price', 'woocommerce' ),
155 'isRequired' => true,
156 'help' => $is_calc_taxes_enabled ? null : sprintf(
157 /* translators: %1$s: store settings link opening tag. %2$s: store settings link closing tag.*/
158 __( 'Per your %1$sstore settings%2$s, taxes are not enabled.', 'woocommerce' ),
159 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '" target="_blank" rel="noreferrer">',
160 '</a>'
161 ),
162 ),
163 )
164 );
165 $pricing_column_2 = $pricing_columns->add_block(
166 array(
167 'id' => 'product-pricing-group-pricing-column-2',
168 'blockName' => 'core/column',
169 'order' => 20,
170 'attributes' => array(
171 'templateLock' => 'all',
172 ),
173 )
174 );
175 $pricing_column_2->add_block(
176 array(
177 'id' => 'product-pricing-sale-price',
178 'blockName' => 'woocommerce/product-sale-price-field',
179 'order' => 10,
180 'attributes' => array(
181 'label' => __( 'Sale price', 'woocommerce' ),
182 ),
183 )
184 );
185 $basic_details->add_block(
186 array(
187 'id' => 'product-pricing-schedule-sale-fields',
188 'blockName' => 'woocommerce/product-schedule-sale-fields',
189 'order' => 20,
190 )
191 );
192
193 if ( $is_calc_taxes_enabled ) {
194 $basic_details->add_block(
195 array(
196 'id' => 'product-tax-class',
197 'blockName' => 'woocommerce/product-select-field',
198 'order' => 40,
199 'attributes' => array(
200 'label' => __( 'Tax class', 'woocommerce' ),
201 'help' => sprintf(
202 /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/
203 __( 'Apply a tax rate if this product qualifies for tax reduction or exemption. %1$sLearn more%2$s', 'woocommerce' ),
204 '<a href="https://woocommerce.com/document/setting-up-taxes-in-woocommerce/#shipping-tax-class" target="_blank" rel="noreferrer">',
205 '</a>'
206 ),
207 'property' => 'tax_class',
208 'options' => SimpleProductTemplate::get_tax_classes( 'product_variation' ),
209 ),
210 )
211 );
212 }
213
214 $basic_details->add_block(
215 array(
216 'id' => 'product-variation-note',
217 'blockName' => 'woocommerce/product-text-area-field',
218 'order' => 20,
219 'attributes' => array(
220 'property' => 'description',
221 'label' => __( 'Note', 'woocommerce' ),
222 'help' => 'Enter an optional note displayed on the product page when customers select this variation.',
223 'lock' => array(
224 'move' => true,
225 ),
226 ),
227 )
228 );
229 $basic_details->add_block(
230 array(
231 'id' => 'product-variation-visibility',
232 'blockName' => 'woocommerce/product-checkbox-field',
233 'order' => 30,
234 'attributes' => array(
235 'property' => 'status',
236 'label' => __( 'Hide in product catalog', 'woocommerce' ),
237 'checkedValue' => 'private',
238 'uncheckedValue' => 'publish',
239 ),
240 )
241 );
242
243 // Images section.
244 $images_section = $general_group->add_section(
245 array(
246 'id' => 'product-variation-images-section',
247 'order' => 30,
248 'attributes' => array(
249 'title' => __( 'Image', 'woocommerce' ),
250 'description' => sprintf(
251 /* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag. */
252 __( 'Drag images, upload new ones or select files from your library. For best results, use JPEG files that are 1000 by 1000 pixels or larger. %1$sHow to prepare images?%2$s', 'woocommerce' ),
253 '<a href="https://woocommerce.com/posts/how-to-take-professional-product-photos-top-tips" target="_blank" rel="noreferrer">',
254 '</a>'
255 ),
256 ),
257 )
258 );
259 $images_section->add_block(
260 array(
261 'id' => 'product-variation-image',
262 'blockName' => 'woocommerce/product-images-field',
263 'order' => 10,
264 'attributes' => array(
265 'property' => 'image',
266 'multiple' => false,
267 ),
268 )
269 );
270
271 // Downloads section.
272 $this->add_downloadable_product_blocks( $general_group );
273 }
274
275 /**
276 * Adds the inventory group blocks to the template.
277 */
278 protected function add_inventory_group_blocks() {
279 $inventory_group = $this->get_group_by_id( $this::GROUP_IDS['INVENTORY'] );
280 $inventory_group->add_block(
281 array(
282 'id' => 'inventory-single-variation-notice',
283 'blockName' => 'woocommerce/product-single-variation-notice',
284 'order' => 10,
285 'attributes' => array(
286 'content' => __( '<strong>You’re editing details specific to this variation.</strong> Some information, like description and images, will be inherited from the main product, <noticeLink><parentProductName/></noticeLink>.', 'woocommerce' ),
287 'type' => 'info',
288 'isDismissible' => true,
289 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION,
290 ),
291 )
292 );
293 // Product Inventory Section.
294 $product_inventory_section = $inventory_group->add_section(
295 array(
296 'id' => 'product-variation-inventory-section',
297 'order' => 20,
298 'attributes' => array(
299 'title' => __( 'Inventory', 'woocommerce' ),
300 'description' => sprintf(
301 /* translators: %1$s: Inventory settings link opening tag. %2$s: Inventory settings link closing tag.*/
302 __( 'Set up and manage inventory for this product, including status and available quantity. %1$sManage store inventory settings%2$s', 'woocommerce' ),
303 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products&section=inventory' ) . '" target="_blank" rel="noreferrer">',
304 '</a>'
305 ),
306 'blockGap' => 'unit-40',
307 ),
308 )
309 );
310 $product_inventory_inner_section = $product_inventory_section->add_subsection(
311 array(
312 'id' => 'product-variation-inventory-inner-section',
313 'order' => 10,
314 )
315 );
316 $inventory_columns = $product_inventory_inner_section->add_block(
317 array(
318 'id' => 'product-inventory-inner-columns',
319 'blockName' => 'core/columns',
320 )
321 );
322 $inventory_columns->add_block(
323 array(
324 'id' => 'product-inventory-inner-column1',
325 'blockName' => 'core/column',
326 )
327 )->add_block(
328 array(
329 'id' => 'product-variation-sku-field',
330 'blockName' => 'woocommerce/product-sku-field',
331 'order' => 10,
332 )
333 );
334 $inventory_columns->add_block(
335 array(
336 'id' => 'product-inventory-inner-column2',
337 'blockName' => 'core/column',
338 )
339 )->add_block(
340 array(
341 'id' => 'product-unique-id-field',
342 'blockName' => 'woocommerce/product-text-field',
343 'order' => 20,
344 'attributes' => array(
345 'property' => 'global_unique_id',
346 // translators: %1$s GTIN %2$s UPC %3$s EAN %4$s ISBN.
347 'label' => sprintf( __( '%1$s, %2$s, %3$s, or %4$s', 'woocommerce' ), '<abbr title="' . esc_attr__( 'Global Trade Item Number', 'woocommerce' ) . '">' . esc_html__( 'GTIN', 'woocommerce' ) . '</abbr>', '<abbr title="' . esc_attr__( 'Universal Product Code', 'woocommerce' ) . '">' . esc_html__( 'UPC', 'woocommerce' ) . '</abbr>', '<abbr title="' . esc_attr__( 'European Article Number', 'woocommerce' ) . '">' . esc_html__( 'EAN', 'woocommerce' ) . '</abbr>', '<abbr title="' . esc_attr__( 'International Standard Book Number', 'woocommerce' ) . '">' . esc_html__( 'ISBN', 'woocommerce' ) . '</abbr>' ),
348 'tooltip' => __( 'Enter a barcode or any other identifier unique to this product. It can help you list this product on other channels or marketplaces.', 'woocommerce' ),
349 'pattern' => array(
350 'value' => '[0-9\-]*[0-9Xx]?',
351 'message' => __( 'Enter only numbers and hyphens (-). The letter X is allowed only as the final ISBN-10 check digit.', 'woocommerce' ),
352 ),
353 ),
354 )
355 );
356 $product_inventory_inner_section->add_block(
357 array(
358 'id' => 'product-variation-track-stock',
359 'blockName' => 'woocommerce/product-toggle-field',
360 'order' => 20,
361 'attributes' => array(
362 'label' => __( 'Track inventory', 'woocommerce' ),
363 'property' => 'manage_stock',
364 'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ),
365 'disabledCopy' => sprintf(
366 /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/
367 __( 'Per your %1$sstore settings%2$s, inventory management is <strong>disabled</strong>.', 'woocommerce' ),
368 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products&section=inventory' ) . '" target="_blank" rel="noreferrer">',
369 '</a>'
370 ),
371 ),
372 )
373 );
374 $product_inventory_inner_section->add_block(
375 array(
376 'id' => 'product-variation-inventory-quantity',
377 'blockName' => 'woocommerce/product-inventory-quantity-field',
378 'order' => 10,
379 'hideConditions' => array(
380 array(
381 'expression' => 'editedProduct.manage_stock === false',
382 ),
383 ),
384 )
385 );
386 $product_inventory_section->add_block(
387 array(
388 'id' => 'product-variation-stock-status',
389 'blockName' => 'woocommerce/product-radio-field',
390 'order' => 10,
391 'attributes' => array(
392 'title' => __( 'Stock status', 'woocommerce' ),
393 'property' => 'stock_status',
394 'options' => array(
395 array(
396 'label' => __( 'In stock', 'woocommerce' ),
397 'value' => ProductStockStatus::IN_STOCK,
398 ),
399 array(
400 'label' => __( 'Out of stock', 'woocommerce' ),
401 'value' => ProductStockStatus::OUT_OF_STOCK,
402 ),
403 array(
404 'label' => __( 'On backorder', 'woocommerce' ),
405 'value' => ProductStockStatus::ON_BACKORDER,
406 ),
407 ),
408 ),
409 'hideConditions' => array(
410 array(
411 'expression' => 'editedProduct.manage_stock === true',
412 ),
413 ),
414 )
415 );
416 }
417
418 /**
419 * Adds the shipping group blocks to the template.
420 */
421 protected function add_shipping_group_blocks() {
422 $shipping_group = $this->get_group_by_id( $this::GROUP_IDS['SHIPPING'] );
423 $shipping_group->add_block(
424 array(
425 'id' => 'shipping-single-variation-notice',
426 'blockName' => 'woocommerce/product-single-variation-notice',
427 'order' => 10,
428 'attributes' => array(
429 'content' => __( '<strong>You’re editing details specific to this variation.</strong> Some information, like description and images, will be inherited from the main product, <noticeLink><parentProductName/></noticeLink>.', 'woocommerce' ),
430 'type' => 'info',
431 'isDismissible' => true,
432 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION,
433 ),
434 )
435 );
436 // Virtual section.
437 $shipping_group->add_section(
438 array(
439 'id' => 'product-variation-virtual-section',
440 'order' => 20,
441 )
442 )->add_block(
443 array(
444 'id' => 'product-variation-virtual',
445 'blockName' => 'woocommerce/product-toggle-field',
446 'order' => 10,
447 'attributes' => array(
448 'property' => 'virtual',
449 'checkedValue' => false,
450 'uncheckedValue' => true,
451 'label' => __( 'This variation requires shipping or pickup', 'woocommerce' ),
452 'uncheckedHelp' => __( 'This variation will not trigger your customer\'s shipping calculator in cart or at checkout. This product also won\'t require your customers to enter their shipping details at checkout. <a href="https://woocommerce.com/document/managing-products/#adding-a-virtual-product" target="_blank" rel="noreferrer">Read more about virtual products</a>.', 'woocommerce' ),
453 ),
454 )
455 );
456 // Product Shipping Section.
457 $product_fee_and_dimensions_section = $shipping_group->add_section(
458 array(
459 'id' => 'product-variation-fee-and-dimensions-section',
460 'order' => 30,
461 'attributes' => array(
462 'title' => __( 'Fees & dimensions', 'woocommerce' ),
463 'description' => sprintf(
464 /* translators: %1$s: How to get started? link opening tag. %2$s: How to get started? link closing tag.*/
465 __( 'Set up shipping costs and enter dimensions used for accurate rate calculations. %1$sHow to get started?%2$s', 'woocommerce' ),
466 '<a href="https://woocommerce.com/posts/how-to-calculate-shipping-costs-for-your-woocommerce-store/" target="_blank" rel="noreferrer">',
467 '</a>'
468 ),
469 ),
470 )
471 );
472 $product_fee_and_dimensions_section->add_block(
473 array(
474 'id' => 'product-variation-shipping-class',
475 'blockName' => 'woocommerce/product-shipping-class-field',
476 'order' => 10,
477 )
478 );
479 $product_fee_and_dimensions_section->add_block(
480 array(
481 'id' => 'product-variation-shipping-dimensions',
482 'blockName' => 'woocommerce/product-shipping-dimensions-fields',
483 'order' => 20,
484 )
485 );
486 }
487 }
488