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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 / SimpleProductTemplate.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
SimpleProductTemplate.php
1205 lines
1 <?php
2 /**
3 * SimpleProductTemplate
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\CatalogVisibility;
11 use Automattic\WooCommerce\Enums\ProductStockStatus;
12 use Automattic\WooCommerce\Enums\ProductTaxStatus;
13 use WC_Tax;
14
15 /**
16 * Simple Product Template.
17 */
18 class SimpleProductTemplate extends AbstractProductFormTemplate implements ProductFormTemplateInterface {
19 use DownloadableProductTrait;
20
21 /**
22 * The context name used to identify the editor.
23 */
24 const GROUP_IDS = array(
25 'GENERAL' => 'general',
26 'ORGANIZATION' => 'organization',
27 'INVENTORY' => 'inventory',
28 'SHIPPING' => 'shipping',
29 'VARIATIONS' => 'variations',
30 'LINKED_PRODUCTS' => 'linked-products',
31 );
32
33 /**
34 * SimpleProductTemplate constructor.
35 */
36 public function __construct() {
37 $this->add_group_blocks();
38 $this->add_general_group_blocks();
39 $this->add_organization_group_blocks();
40 $this->add_inventory_group_blocks();
41 $this->add_shipping_group_blocks();
42 $this->add_variation_group_blocks();
43 $this->add_linked_products_group_blocks();
44 }
45
46 /**
47 * Get the template ID.
48 */
49 public function get_id(): string {
50 return 'simple-product';
51 }
52
53 /**
54 * Get the template title.
55 */
56 public function get_title(): string {
57 return __( 'Simple Product Template', 'woocommerce' );
58 }
59
60 /**
61 * Get the template description.
62 */
63 public function get_description(): string {
64 return __( 'Template for the simple product form', 'woocommerce' );
65 }
66
67 /**
68 * Adds the group blocks to the template.
69 */
70 private function add_group_blocks() {
71 $this->add_group(
72 array(
73 'id' => $this::GROUP_IDS['GENERAL'],
74 'order' => 10,
75 'attributes' => array(
76 'title' => __( 'General', 'woocommerce' ),
77 ),
78 )
79 );
80
81 // Variations tab.
82 $variations_hide_conditions = array();
83 $variations_hide_conditions[] = array(
84 'expression' => 'editedProduct.type === "grouped"',
85 );
86 $variations_hide_conditions[] = array(
87 'expression' => 'editedProduct.type === "external"',
88 );
89
90 $this->add_group(
91 array(
92 'id' => $this::GROUP_IDS['VARIATIONS'],
93 'order' => 20,
94 'attributes' => array(
95 'title' => __( 'Variations', 'woocommerce' ),
96 ),
97 'hideConditions' => $variations_hide_conditions,
98 )
99 );
100
101 $this->add_group(
102 array(
103 'id' => $this::GROUP_IDS['ORGANIZATION'],
104 'order' => 30,
105 'attributes' => array(
106 'title' => __( 'Organization', 'woocommerce' ),
107 ),
108 )
109 );
110 $this->add_group(
111 array(
112 'id' => $this::GROUP_IDS['INVENTORY'],
113 'order' => 50,
114 'attributes' => array(
115 'title' => __( 'Inventory', 'woocommerce' ),
116 ),
117 )
118 );
119 $shipping_hide_conditions = array();
120 $shipping_hide_conditions[] = array(
121 'expression' => 'editedProduct.type === "grouped"',
122 );
123 $shipping_hide_conditions[] = array(
124 'expression' => 'editedProduct.type === "external"',
125 );
126
127 $this->add_group(
128 array(
129 'id' => $this::GROUP_IDS['SHIPPING'],
130 'order' => 60,
131 'attributes' => array(
132 'title' => __( 'Shipping', 'woocommerce' ),
133 ),
134 'hideConditions' => $shipping_hide_conditions,
135 )
136 );
137
138 // Linked Products tab.
139 $this->add_group(
140 array(
141 'id' => $this::GROUP_IDS['LINKED_PRODUCTS'],
142 'order' => 70,
143 'attributes' => array(
144 'title' => __( 'Linked products', 'woocommerce' ),
145 ),
146 )
147 );
148 }
149
150 /**
151 * Adds the general group blocks to the template.
152 */
153 private function add_general_group_blocks() {
154 $is_calc_taxes_enabled = wc_tax_enabled();
155 $general_group = $this->get_group_by_id( $this::GROUP_IDS['GENERAL'] );
156 $general_group->add_block(
157 array(
158 'id' => 'product_variation_notice_general_tab',
159 'blockName' => 'woocommerce/product-has-variations-notice',
160 'order' => 10,
161 'attributes' => array(
162 'content' => __( 'This product has options, such as size or color. You can manage each variation\'s images, downloads, and other details individually.', 'woocommerce' ),
163 'buttonText' => __( 'Go to Variations', 'woocommerce' ),
164 'type' => 'info',
165 ),
166 )
167 );
168 // Basic Details Section.
169 $basic_details = $general_group->add_section(
170 array(
171 'id' => 'basic-details',
172 'order' => 10,
173 'attributes' => array(
174 'title' => __( 'Basic details', 'woocommerce' ),
175 'description' => __( 'This info will be displayed on the product page, category pages, social media, and search results.', 'woocommerce' ),
176 ),
177 )
178 );
179 $basic_details->add_block(
180 array(
181 'id' => 'product-details-section-description',
182 'blockName' => 'woocommerce/product-details-section-description',
183 'order' => 10,
184 )
185 );
186 $basic_details->add_block(
187 array(
188 'id' => 'product-name',
189 'blockName' => 'woocommerce/product-name-field',
190 'order' => 10,
191 'attributes' => array(
192 'name' => 'Product name',
193 'autoFocus' => true,
194 'metadata' => array(
195 'bindings' => array(
196 'value' => array(
197 'source' => 'woocommerce/entity-product',
198 'args' => array(
199 'prop' => 'name',
200 ),
201 ),
202 ),
203 ),
204 ),
205 )
206 );
207
208 // Product Pricing columns.
209 $pricing_columns = $basic_details->add_block(
210 array(
211 'id' => 'product-pricing-group-pricing-columns',
212 'blockName' => 'core/columns',
213 'order' => 10,
214 )
215 );
216 $pricing_column_1 = $pricing_columns->add_block(
217 array(
218 'id' => 'product-pricing-group-pricing-column-1',
219 'blockName' => 'core/column',
220 'order' => 10,
221 'attributes' => array(
222 'templateLock' => 'all',
223 ),
224 )
225 );
226 $pricing_column_1->add_block(
227 array(
228 'id' => 'product-pricing-regular-price',
229 'blockName' => 'woocommerce/product-regular-price-field',
230 'order' => 10,
231 'attributes' => array(
232 'name' => 'regular_price',
233 'label' => __( 'Regular price', 'woocommerce' ),
234 'help' => $is_calc_taxes_enabled ? null : sprintf(
235 /* translators: %1$s: store settings link opening tag. %2$s: store settings link closing tag.*/
236 __( 'Per your %1$sstore settings%2$s, taxes are not enabled.', 'woocommerce' ),
237 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '" target="_blank" rel="noreferrer">',
238 '</a>'
239 ),
240 ),
241 'disableConditions' => array(
242 array(
243 'expression' => 'editedProduct.type === "variable"',
244 ),
245 array(
246 'expression' => 'editedProduct.type === "grouped"',
247 ),
248 ),
249 )
250 );
251 $pricing_column_2 = $pricing_columns->add_block(
252 array(
253 'id' => 'product-pricing-group-pricing-column-2',
254 'blockName' => 'core/column',
255 'order' => 20,
256 'attributes' => array(
257 'templateLock' => 'all',
258 ),
259 )
260 );
261 $pricing_column_2->add_block(
262 array(
263 'id' => 'product-pricing-sale-price',
264 'blockName' => 'woocommerce/product-sale-price-field',
265 'order' => 10,
266 'attributes' => array(
267 'label' => __( 'Sale price', 'woocommerce' ),
268 ),
269 'disableConditions' => array(
270 array(
271 'expression' => 'editedProduct.type === "variable"',
272 ),
273 array(
274 'expression' => 'editedProduct.type === "grouped"',
275 ),
276 ),
277 )
278 );
279 $basic_details->add_block(
280 array(
281 'id' => 'product-pricing-schedule-sale-fields',
282 'blockName' => 'woocommerce/product-schedule-sale-fields',
283 'order' => 20,
284 )
285 );
286
287 if ( $is_calc_taxes_enabled ) {
288 $basic_details->add_block(
289 array(
290 'id' => 'product-sale-tax',
291 'blockName' => 'woocommerce/product-radio-field',
292 'order' => 30,
293 'attributes' => array(
294 'title' => __( 'Charge sales tax on', 'woocommerce' ),
295 'property' => 'tax_status',
296 'options' => array(
297 array(
298 'label' => __( 'Product and shipping', 'woocommerce' ),
299 'value' => ProductTaxStatus::TAXABLE,
300 ),
301 array(
302 'label' => __( 'Only shipping', 'woocommerce' ),
303 'value' => 'shipping',
304 ),
305 array(
306 'label' => __( "Don't charge tax", 'woocommerce' ),
307 'value' => 'none',
308 ),
309 ),
310 ),
311 )
312 );
313 $pricing_advanced_block = $basic_details->add_block(
314 array(
315 'id' => 'product-pricing-advanced',
316 'blockName' => 'woocommerce/product-collapsible',
317 'order' => 40,
318 'attributes' => array(
319 'toggleText' => __( 'Advanced', 'woocommerce' ),
320 'initialCollapsed' => true,
321 'persistRender' => true,
322 ),
323 )
324 );
325 $pricing_advanced_block->add_block(
326 array(
327 'id' => 'product-tax-class',
328 'blockName' => 'woocommerce/product-select-field',
329 'order' => 10,
330 'attributes' => array(
331 'label' => __( 'Tax class', 'woocommerce' ),
332 'help' => sprintf(
333 /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/
334 __( 'Apply a tax rate if this product qualifies for tax reduction or exemption. %1$sLearn more%2$s', 'woocommerce' ),
335 '<a href="https://woocommerce.com/document/setting-up-taxes-in-woocommerce/#shipping-tax-class" target="_blank" rel="noreferrer">',
336 '</a>'
337 ),
338 'property' => 'tax_class',
339 'options' => self::get_tax_classes(),
340 ),
341 )
342 );
343 }
344
345 $basic_details->add_block(
346 array(
347 'id' => 'product-summary',
348 'blockName' => 'woocommerce/product-text-area-field',
349 'order' => 50,
350 'attributes' => array(
351 'label' => __( 'Summary', 'woocommerce' ),
352 'help' => __(
353 "Summarize this product in 1-2 short sentences. We'll show it at the top of the page.",
354 'woocommerce'
355 ),
356 'property' => 'short_description',
357 'lock' => array(
358 'move' => true,
359 ),
360 ),
361 )
362 );
363
364 // Description section.
365 $description_section = $general_group->add_section(
366 array(
367 'id' => 'product-description-section',
368 'order' => 20,
369 'attributes' => array(
370 'title' => __( 'Description', 'woocommerce' ),
371 'description' => __( 'What makes this product unique? What are its most important features? Enrich the product page by adding rich content using blocks.', 'woocommerce' ),
372 ),
373 )
374 );
375
376 $description_field_block = $description_section->add_block(
377 array(
378 'id' => 'product-description',
379 'blockName' => 'woocommerce/product-description-field',
380 'order' => 10,
381 )
382 );
383
384 $description_field_block->add_block(
385 array(
386 'id' => 'product-description__content',
387 'blockName' => 'woocommerce/product-summary-field',
388 'order' => 10,
389 'attributes' => array(
390 'helpText' => null,
391 'label' => null,
392 'property' => 'description',
393 'lock' => array(
394 'move' => true,
395 ),
396 ),
397 )
398 );
399
400 // External/Affiliate section.
401 $buy_button_section = $general_group->add_section(
402 array(
403 'id' => 'product-buy-button-section',
404 'order' => 30,
405 'attributes' => array(
406 'title' => __( 'Buy button', 'woocommerce' ),
407 'description' => __( 'Add a link and choose a label for the button linked to a product sold elsewhere.', 'woocommerce' ),
408 ),
409 'hideConditions' => array(
410 array(
411 'expression' => 'editedProduct.type !== "external"',
412 ),
413 ),
414 )
415 );
416
417 $buy_button_section->add_block(
418 array(
419 'id' => 'product-external-url',
420 'blockName' => 'woocommerce/product-text-field',
421 'order' => 10,
422 'attributes' => array(
423 'property' => 'external_url',
424 'label' => __( 'Link to the external product', 'woocommerce' ),
425 'placeholder' => __( 'Enter the external URL to the product', 'woocommerce' ),
426 'suffix' => true,
427 'type' => array(
428 'value' => 'url',
429 'message' => __( 'Link to the external product is an invalid URL.', 'woocommerce' ),
430 ),
431 ),
432 )
433 );
434
435 $button_text_columns = $buy_button_section->add_block(
436 array(
437 'id' => 'product-button-text-columns',
438 'blockName' => 'core/columns',
439 'order' => 20,
440 )
441 );
442
443 $button_text_columns->add_block(
444 array(
445 'id' => 'product-button-text-column1',
446 'blockName' => 'core/column',
447 'order' => 10,
448 )
449 )->add_block(
450 array(
451 'id' => 'product-button-text',
452 'blockName' => 'woocommerce/product-text-field',
453 'order' => 10,
454 'attributes' => array(
455 'property' => 'button_text',
456 'label' => __( 'Buy button text', 'woocommerce' ),
457 ),
458 )
459 );
460
461 $button_text_columns->add_block(
462 array(
463 'id' => 'product-button-text-column2',
464 'blockName' => 'core/column',
465 'order' => 20,
466 )
467 );
468
469 // Product list section.
470 $product_list_section = $general_group->add_section(
471 array(
472 'id' => 'product-list-section',
473 'order' => 35,
474 'attributes' => array(
475 'title' => __( 'Products in this group', 'woocommerce' ),
476 'description' => __( 'Make a collection of related products, enabling customers to purchase multiple items together.', 'woocommerce' ),
477 ),
478 'hideConditions' => array(
479 array(
480 'expression' => 'editedProduct.type !== "grouped"',
481 ),
482 ),
483 )
484 );
485
486 $product_list_section->add_block(
487 array(
488 'id' => 'product-list',
489 'blockName' => 'woocommerce/product-list-field',
490 'order' => 10,
491 'attributes' => array(
492 'property' => 'grouped_products',
493 ),
494 )
495 );
496
497 // Images section.
498 $images_section = $general_group->add_section(
499 array(
500 'id' => 'product-images-section',
501 'order' => 40,
502 'attributes' => array(
503 'title' => __( 'Images', 'woocommerce' ),
504 'description' => sprintf(
505 /* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag. */
506 __( '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' ),
507 '<a href="https://woocommerce.com/posts/how-to-take-professional-product-photos-top-tips" target="_blank" rel="noreferrer">',
508 '</a>'
509 ),
510 ),
511 )
512 );
513 $images_section->add_block(
514 array(
515 'id' => 'product-images',
516 'blockName' => 'woocommerce/product-images-field',
517 'order' => 10,
518 'attributes' => array(
519 'images' => array(),
520 'property' => 'images',
521 ),
522 )
523 );
524
525 // Downloads section.
526 $this->add_downloadable_product_blocks( $general_group );
527 }
528
529 /**
530 * Adds the organization group blocks to the template.
531 */
532 private function add_organization_group_blocks() {
533 $organization_group = $this->get_group_by_id( $this::GROUP_IDS['ORGANIZATION'] );
534 // Product Catalog Section.
535 $product_catalog_section = $organization_group->add_section(
536 array(
537 'id' => 'product-catalog-section',
538 'order' => 10,
539 'attributes' => array(
540 'title' => __( 'Product catalog', 'woocommerce' ),
541 'description' => __( 'Help customers find this product by assigning it to categories, adding extra details, and managing its visibility in your store and other channels.', 'woocommerce' ),
542 ),
543 )
544 );
545 $product_catalog_section->add_block(
546 array(
547 'id' => 'product-categories',
548 'blockName' => 'woocommerce/product-taxonomy-field',
549 'order' => 10,
550 'attributes' => array(
551 'slug' => 'product_cat',
552 'property' => 'categories',
553 'label' => __( 'Categories', 'woocommerce' ),
554 'createTitle' => __( 'Create new category', 'woocommerce' ),
555 'dialogNameHelpText' => __( 'Shown to customers on the product page.', 'woocommerce' ),
556 'parentTaxonomyText' => __( 'Parent category', 'woocommerce' ),
557 'placeholder' => __( 'Search or create categories…', 'woocommerce' ),
558 ),
559 )
560 );
561 $product_catalog_section->add_block(
562 array(
563 'id' => 'product-tags',
564 'blockName' => 'woocommerce/product-tag-field',
565 'attributes' => array(
566 'name' => 'tags',
567 ),
568 )
569 );
570 $product_catalog_section->add_block(
571 array(
572 'id' => 'product-catalog-search-visibility',
573 'blockName' => 'woocommerce/product-catalog-visibility-field',
574 'order' => 20,
575 'attributes' => array(
576 'label' => __( 'Hide in product catalog', 'woocommerce' ),
577 'visibility' => CatalogVisibility::SEARCH,
578 ),
579 )
580 );
581 $product_catalog_section->add_block(
582 array(
583 'id' => 'product-catalog-catalog-visibility',
584 'blockName' => 'woocommerce/product-catalog-visibility-field',
585 'order' => 30,
586 'attributes' => array(
587 'label' => __( 'Hide from search results', 'woocommerce' ),
588 'visibility' => CatalogVisibility::CATALOG,
589 ),
590 )
591 );
592 $product_catalog_section->add_block(
593 array(
594 'id' => 'product-enable-product-reviews',
595 'blockName' => 'woocommerce/product-checkbox-field',
596 'order' => 40,
597 'attributes' => array(
598 'label' => __( 'Enable product reviews', 'woocommerce' ),
599 'property' => 'reviews_allowed',
600 ),
601 )
602 );
603 $product_catalog_section->add_block(
604 array(
605 'id' => 'product-post-password',
606 'blockName' => 'woocommerce/product-password-field',
607 'order' => 50,
608 'attributes' => array(
609 'label' => __( 'Require a password', 'woocommerce' ),
610 ),
611 )
612 );
613 // Attributes section.
614 $product_attributes_section = $organization_group->add_section(
615 array(
616 'id' => 'product-attributes-section',
617 'order' => 20,
618 'attributes' => array(
619 'title' => __( 'Attributes', 'woocommerce' ),
620 'description' => __( 'Use global attributes to allow shoppers to filter and search for this product. Use custom attributes to provide detailed product information.', 'woocommerce' ),
621 'blockGap' => 'unit-40',
622 ),
623 )
624 );
625 $product_attributes_section->add_block(
626 array(
627 'id' => 'product-attributes',
628 'blockName' => 'woocommerce/product-attributes-field',
629 'order' => 10,
630 )
631 );
632
633 if ( Features::is_enabled( 'product-custom-fields' ) ) {
634 $organization_group->add_section(
635 array(
636 'id' => 'product-custom-fields-wrapper-section',
637 'order' => 30,
638 )
639 )->add_block(
640 array(
641 'id' => 'product-custom-fields-toggle',
642 'blockName' => 'woocommerce/product-custom-fields-toggle-field',
643 'order' => 10,
644 'attributes' => array(
645 'label' => __( 'Show custom fields', 'woocommerce' ),
646 ),
647 )
648 )->add_block(
649 array(
650 'id' => 'product-custom-fields-section',
651 'blockName' => 'woocommerce/product-section',
652 'order' => 10,
653 'attributes' => array(
654 'blockGap' => 'unit-30',
655 'title' => __( 'Custom fields', 'woocommerce' ),
656 'description' => sprintf(
657 /* translators: %1$s: Custom fields guide link opening tag. %2$s: Custom fields guide link closing tag. */
658 __( 'Custom fields can be used in a variety of ways, such as sharing more detailed product information, showing more input fields, or for internal inventory organization. %1$sRead more about custom fields%2$s', 'woocommerce' ),
659 '<a href="https://woocommerce.com/document/custom-product-fields/" target="_blank" rel="noreferrer">',
660 '</a>'
661 ),
662 ),
663 )
664 )->add_block(
665 array(
666 'id' => 'product-custom-fields',
667 'blockName' => 'woocommerce/product-custom-fields',
668 'order' => 10,
669 )
670 );
671 }
672 }
673
674 /**
675 * Get the tax classes as select options.
676 *
677 * @param string $post_type The post type.
678 * @return array Array of options.
679 */
680 public static function get_tax_classes( $post_type = 'product' ) {
681 $tax_classes = array();
682
683 if ( 'product_variation' === $post_type ) {
684 $tax_classes[] = array(
685 'label' => __( 'Same as main product', 'woocommerce' ),
686 'value' => 'parent',
687 );
688 }
689
690 // Add standard class.
691 $tax_classes[] = array(
692 'label' => __( 'Standard rate', 'woocommerce' ),
693 'value' => '',
694 );
695
696 $classes = WC_Tax::get_tax_rate_classes();
697
698 foreach ( $classes as $tax_class ) {
699 $tax_classes[] = array(
700 'label' => $tax_class->name,
701 'value' => $tax_class->slug,
702 );
703 }
704
705 return $tax_classes;
706 }
707
708 /**
709 * Adds the inventory group blocks to the template.
710 */
711 private function add_inventory_group_blocks() {
712 $inventory_group = $this->get_group_by_id( $this::GROUP_IDS['INVENTORY'] );
713 $inventory_group->add_block(
714 array(
715 'id' => 'product_variation_notice_inventory_tab',
716 'blockName' => 'woocommerce/product-has-variations-notice',
717 'order' => 10,
718 'attributes' => array(
719 'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s inventory and other details individually.', 'woocommerce' ),
720 'buttonText' => __( 'Go to Variations', 'woocommerce' ),
721 'type' => 'info',
722 ),
723 )
724 );
725 // Product Inventory Section.
726 $product_inventory_section = $inventory_group->add_section(
727 array(
728 'id' => 'product-inventory-section',
729 'order' => 20,
730 'attributes' => array(
731 'title' => __( 'Inventory', 'woocommerce' ),
732 'description' => sprintf(
733 /* translators: %1$s: Inventory settings link opening tag. %2$s: Inventory settings link closing tag.*/
734 __( 'Set up and manage inventory for this product, including status and available quantity. %1$sManage store inventory settings%2$s', 'woocommerce' ),
735 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products&section=inventory' ) . '" target="_blank" rel="noreferrer">',
736 '</a>'
737 ),
738 'blockGap' => 'unit-40',
739 ),
740 )
741 );
742 $product_inventory_inner_section = $product_inventory_section->add_subsection(
743 array(
744 'id' => 'product-inventory-inner-section',
745 'order' => 10,
746 )
747 );
748 $inventory_columns = $product_inventory_inner_section->add_block(
749 array(
750 'id' => 'product-inventory-inner-columns',
751 'blockName' => 'core/columns',
752 )
753 );
754 $inventory_columns->add_block(
755 array(
756 'id' => 'product-inventory-inner-column1',
757 'blockName' => 'core/column',
758 )
759 )->add_block(
760 array(
761 'id' => 'product-sku-field',
762 'blockName' => 'woocommerce/product-sku-field',
763 'order' => 10,
764 'disableConditions' => array(
765 array(
766 'expression' => 'editedProduct.type === "variable"',
767 ),
768 ),
769 )
770 );
771 $inventory_columns->add_block(
772 array(
773 'id' => 'product-inventory-inner-column2',
774 'blockName' => 'core/column',
775 )
776 )->add_block(
777 array(
778 'id' => 'product-unique-id-field',
779 'blockName' => 'woocommerce/product-text-field',
780 'order' => 20,
781 'attributes' => array(
782 'property' => 'global_unique_id',
783 // translators: %1$s GTIN %2$s UPC %3$s EAN %4$s ISBN.
784 '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>' ),
785 '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' ),
786 'pattern' => array(
787 'value' => '[0-9\-]*[0-9Xx]?',
788 'message' => __( 'Enter only numbers and hyphens (-). The letter X is allowed only as the final ISBN-10 check digit.', 'woocommerce' ),
789 ),
790 ),
791 'disableConditions' => array(
792 array(
793 'expression' => 'editedProduct.type === "variable"',
794 ),
795 ),
796 )
797 );
798
799 $manage_stock = 'yes' === get_option( 'woocommerce_manage_stock' );
800 $product_inventory_inner_section->add_block(
801 array(
802 'id' => 'product-track-stock',
803 'blockName' => 'woocommerce/product-toggle-field',
804 'order' => 20,
805 'attributes' => array(
806 'label' => __( 'Track inventory', 'woocommerce' ),
807 'property' => 'manage_stock',
808 'disabled' => ! $manage_stock,
809 'disabledCopy' => ! $manage_stock ? sprintf(
810 /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/
811 __( 'Per your %1$sstore settings%2$s, inventory management is <strong>disabled</strong>.', 'woocommerce' ),
812 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products&section=inventory' ) . '" target="_blank" rel="noreferrer">',
813 '</a>'
814 ) : null,
815 ),
816 'hideConditions' => array(
817 array(
818 'expression' => 'editedProduct.type === "external" || editedProduct.type === "grouped"',
819 ),
820 ),
821 'disableConditions' => array(
822 array(
823 'expression' => 'editedProduct.type === "variable"',
824 ),
825 ),
826 )
827 );
828 $product_inventory_quantity_hide_conditions = array(
829 array(
830 'expression' => 'editedProduct.manage_stock === false',
831 ),
832 );
833 $product_inventory_quantity_hide_conditions[] = array(
834 'expression' => 'editedProduct.type === "grouped"',
835 );
836 $product_inventory_inner_section->add_block(
837 array(
838 'id' => 'product-inventory-quantity',
839 'blockName' => 'woocommerce/product-inventory-quantity-field',
840 'order' => 30,
841 'hideConditions' => $product_inventory_quantity_hide_conditions,
842 )
843 );
844 $product_stock_status_hide_conditions = array(
845 array(
846 'expression' => 'editedProduct.manage_stock === true',
847 ),
848 );
849 $product_stock_status_hide_conditions[] = array(
850 'expression' => 'editedProduct.type === "grouped"',
851 );
852 $product_inventory_section->add_block(
853 array(
854 'id' => 'product-stock-status',
855 'blockName' => 'woocommerce/product-radio-field',
856 'order' => 10,
857 'attributes' => array(
858 'title' => __( 'Stock status', 'woocommerce' ),
859 'property' => 'stock_status',
860 'options' => array(
861 array(
862 'label' => __( 'In stock', 'woocommerce' ),
863 'value' => ProductStockStatus::IN_STOCK,
864 ),
865 array(
866 'label' => __( 'Out of stock', 'woocommerce' ),
867 'value' => ProductStockStatus::OUT_OF_STOCK,
868 ),
869 array(
870 'label' => __( 'On backorder', 'woocommerce' ),
871 'value' => ProductStockStatus::ON_BACKORDER,
872 ),
873 ),
874 ),
875 'hideConditions' => $product_stock_status_hide_conditions,
876 'disableConditions' => array(
877 array(
878 'expression' => 'editedProduct.type === "variable"',
879 ),
880 ),
881 )
882 );
883
884 $product_inventory_section->add_block(
885 array(
886 'id' => 'product-purchase-note',
887 'blockName' => 'woocommerce/product-text-area-field',
888 'order' => 20,
889 'attributes' => array(
890 'property' => 'purchase_note',
891 'label' => __( 'Post-purchase note', 'woocommerce' ),
892 'placeholder' => __( 'Enter an optional note attached to the order confirmation message sent to the shopper.', 'woocommerce' ),
893 'lock' => array(
894 'move' => true,
895 ),
896 ),
897 )
898 );
899
900 $product_inventory_advanced = $product_inventory_section->add_block(
901 array(
902 'id' => 'product-inventory-advanced',
903 'blockName' => 'woocommerce/product-collapsible',
904 'order' => 30,
905 'attributes' => array(
906 'toggleText' => __( 'Advanced', 'woocommerce' ),
907 'initialCollapsed' => true,
908 'persistRender' => true,
909 ),
910 'hideConditions' => array(
911 array(
912 'expression' => 'editedProduct.type === "grouped"',
913 ),
914 ),
915 )
916 );
917 $product_inventory_advanced_wrapper = $product_inventory_advanced->add_block(
918 array(
919 'blockName' => 'woocommerce/product-section',
920 'order' => 10,
921 'attributes' => array(
922 'blockGap' => 'unit-40',
923 ),
924 )
925 );
926 $product_inventory_advanced_wrapper->add_block(
927 array(
928 'id' => 'product-out-of-stock',
929 'blockName' => 'woocommerce/product-radio-field',
930 'order' => 10,
931 'attributes' => array(
932 'title' => __( 'When out of stock', 'woocommerce' ),
933 'property' => 'backorders',
934 'options' => array(
935 array(
936 'label' => __( 'Allow purchases', 'woocommerce' ),
937 'value' => 'yes',
938 ),
939 array(
940 'label' => __(
941 'Allow purchases, but notify customers',
942 'woocommerce'
943 ),
944 'value' => 'notify',
945 ),
946 array(
947 'label' => __( "Don't allow purchases", 'woocommerce' ),
948 'value' => 'no',
949 ),
950 ),
951 ),
952 'hideConditions' => array(
953 array(
954 'expression' => 'editedProduct.manage_stock === false',
955 ),
956 ),
957 )
958 );
959 $product_inventory_advanced_wrapper->add_block(
960 array(
961 'id' => 'product-inventory-email',
962 'blockName' => 'woocommerce/product-inventory-email-field',
963 'order' => 20,
964 'hideConditions' => array(
965 array(
966 'expression' => 'editedProduct.manage_stock === false',
967 ),
968 ),
969 )
970 );
971
972 $product_inventory_advanced_wrapper->add_block(
973 array(
974 'id' => 'product-limit-purchase',
975 'blockName' => 'woocommerce/product-checkbox-field',
976 'order' => 20,
977 'attributes' => array(
978 'title' => __(
979 'Restrictions',
980 'woocommerce'
981 ),
982 'label' => __(
983 'Limit purchases to 1 item per order',
984 'woocommerce'
985 ),
986 'property' => 'sold_individually',
987 'tooltip' => __(
988 'When checked, customers will be able to purchase only 1 item in a single order. This is particularly useful for items that have limited quantity, like art or handmade goods.',
989 'woocommerce'
990 ),
991 ),
992 )
993 );
994 }
995
996 /**
997 * Adds the shipping group blocks to the template.
998 */
999 private function add_shipping_group_blocks() {
1000 $shipping_group = $this->get_group_by_id( $this::GROUP_IDS['SHIPPING'] );
1001 $shipping_group->add_block(
1002 array(
1003 'id' => 'product_variation_notice_shipping_tab',
1004 'blockName' => 'woocommerce/product-has-variations-notice',
1005 'order' => 10,
1006 'attributes' => array(
1007 'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s shipping settings and other details individually.', 'woocommerce' ),
1008 'buttonText' => __( 'Go to Variations', 'woocommerce' ),
1009 'type' => 'info',
1010 ),
1011 )
1012 );
1013 // Virtual section.
1014 $shipping_group->add_section(
1015 array(
1016 'id' => 'product-virtual-section',
1017 'order' => 10,
1018 'hideConditions' => array(
1019 array(
1020 'expression' => 'editedProduct.type !== "simple"',
1021 ),
1022 ),
1023 )
1024 )->add_block(
1025 array(
1026 'id' => 'product-virtual',
1027 'blockName' => 'woocommerce/product-toggle-field',
1028 'order' => 10,
1029 'attributes' => array(
1030 'property' => 'virtual',
1031 'checkedValue' => false,
1032 'uncheckedValue' => true,
1033 'label' => __( 'This product requires shipping or pickup', 'woocommerce' ),
1034 'uncheckedHelp' => __( 'This product 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' ),
1035 ),
1036 )
1037 );
1038 // Product Shipping Section.
1039 $product_fee_and_dimensions_section = $shipping_group->add_section(
1040 array(
1041 'id' => 'product-fee-and-dimensions-section',
1042 'order' => 20,
1043 'attributes' => array(
1044 'title' => __( 'Fees & dimensions', 'woocommerce' ),
1045 'description' => sprintf(
1046 /* translators: %1$s: How to get started? link opening tag. %2$s: How to get started? link closing tag.*/
1047 __( 'Set up shipping costs and enter dimensions used for accurate rate calculations. %1$sHow to get started?%2$s', 'woocommerce' ),
1048 '<a href="https://woocommerce.com/posts/how-to-calculate-shipping-costs-for-your-woocommerce-store/" target="_blank" rel="noreferrer">',
1049 '</a>'
1050 ),
1051 ),
1052 )
1053 );
1054 $product_fee_and_dimensions_section->add_block(
1055 array(
1056 'id' => 'product-shipping-class',
1057 'blockName' => 'woocommerce/product-shipping-class-field',
1058 'order' => 10,
1059 'disableConditions' => array(
1060 array(
1061 'expression' => 'editedProduct.type === "variable"',
1062 ),
1063 ),
1064 )
1065 );
1066 $product_fee_and_dimensions_section->add_block(
1067 array(
1068 'id' => 'product-shipping-dimensions',
1069 'blockName' => 'woocommerce/product-shipping-dimensions-fields',
1070 'order' => 20,
1071 'disableConditions' => array(
1072 array(
1073 'expression' => 'editedProduct.type === "variable"',
1074 ),
1075 ),
1076 )
1077 );
1078 }
1079
1080 /**
1081 * Adds the variation group blocks to the template.
1082 */
1083 private function add_variation_group_blocks() {
1084 $variation_group = $this->get_group_by_id( $this::GROUP_IDS['VARIATIONS'] );
1085 if ( ! $variation_group ) {
1086 return;
1087 }
1088
1089 $variation_group->add_section(
1090 array(
1091 'id' => 'product-variation-options-section',
1092 'order' => 10,
1093 'attributes' => array(
1094 'title' => __( 'Variation options', 'woocommerce' ),
1095 'description' => __( 'Add and manage attributes used for product options, such as size and color.', 'woocommerce' ),
1096 ),
1097 )
1098 )->add_block(
1099 array(
1100 'id' => 'product-variation-options',
1101 'blockName' => 'woocommerce/product-variations-options-field',
1102 'order' => 10,
1103 )
1104 );
1105
1106 $variation_group->add_section(
1107 array(
1108 'id' => 'product-variation-section',
1109 'order' => 20,
1110 'attributes' => array(
1111 'title' => __( 'Variations', 'woocommerce' ),
1112 'description' => __( 'Manage individual product combinations created from options.', 'woocommerce' ),
1113 ),
1114 )
1115 )->add_block(
1116 array(
1117 'id' => 'product-variation-items',
1118 'blockName' => 'woocommerce/product-variation-items-field',
1119 'order' => 10,
1120 )
1121 );
1122 }
1123
1124 /**
1125 * Adds the linked products group blocks to the template.
1126 */
1127 private function add_linked_products_group_blocks() {
1128 $linked_products_group = $this->get_group_by_id( $this::GROUP_IDS['LINKED_PRODUCTS'] );
1129 if ( ! isset( $linked_products_group ) ) {
1130 return;
1131 }
1132
1133 $linked_products_group->add_section(
1134 array(
1135 'id' => 'product-linked-upsells-section',
1136 'order' => 10,
1137 'attributes' => array(
1138 'title' => __( 'Upsells', 'woocommerce' ),
1139 'description' => sprintf(
1140 /* translators: %1$s: "Learn more about linked products" link opening tag. %2$s: "Learn more about linked products" link closing tag. */
1141 __( 'Upsells are typically products that are extra profitable or better quality or more expensive. Experiment with combinations to boost sales. %1$sLearn more about linked products%2$s', 'woocommerce' ),
1142 '<br /><a href="https://woocommerce.com/document/related-products-up-sells-and-cross-sells/" target="_blank" rel="noreferrer">',
1143 '</a>'
1144 ),
1145 ),
1146 )
1147 )->add_block(
1148 array(
1149 'id' => 'product-linked-upsells',
1150 'blockName' => 'woocommerce/product-linked-list-field',
1151 'order' => 10,
1152 'attributes' => array(
1153 'property' => 'upsell_ids',
1154 'emptyState' => array(
1155 'image' => 'ShoppingBags',
1156 'tip' => __(
1157 'Tip: Upsells are products that are extra profitable or better quality or more expensive. Experiment with combinations to boost sales.',
1158 'woocommerce'
1159 ),
1160 'isDismissible' => true,
1161 ),
1162 ),
1163 )
1164 );
1165
1166 $linked_products_group->add_section(
1167 array(
1168 'id' => 'product-linked-cross-sells-section',
1169 'order' => 20,
1170 'attributes' => array(
1171 'title' => __( 'Cross-sells', 'woocommerce' ),
1172 'description' => sprintf(
1173 /* translators: %1$s: "Learn more about linked products" link opening tag. %2$s: "Learn more about linked products" link closing tag. */
1174 __( 'By suggesting complementary products in the cart using cross-sells, you can significantly increase the average order value. %1$sLearn more about linked products%2$s', 'woocommerce' ),
1175 '<br /><a href="https://woocommerce.com/document/related-products-up-sells-and-cross-sells/" target="_blank" rel="noreferrer">',
1176 '</a>'
1177 ),
1178 ),
1179 'hideConditions' => array(
1180 array(
1181 'expression' => 'editedProduct.type === "external" || editedProduct.type === "grouped"',
1182 ),
1183 ),
1184 )
1185 )->add_block(
1186 array(
1187 'id' => 'product-linked-cross-sells',
1188 'blockName' => 'woocommerce/product-linked-list-field',
1189 'order' => 10,
1190 'attributes' => array(
1191 'property' => 'cross_sell_ids',
1192 'emptyState' => array(
1193 'image' => 'CashRegister',
1194 'tip' => __(
1195 'Tip: By suggesting complementary products in the cart using cross-sells, you can significantly increase the average order value.',
1196 'woocommerce'
1197 ),
1198 'isDismissible' => true,
1199 ),
1200 ),
1201 )
1202 );
1203 }
1204 }
1205