Migrate Product Price to `block.json` (#50905)

* Migrate Product Price to block.json

* Add changelog

* Update block references

* Update block references and doc manifest

* Add shared config properties to Product Price block.json

* Update block references and docs manifest
This commit is contained in:
Karol Manijak 2024-08-30 07:47:03 +02:00 committed by GitHub
parent a40f87b9ec
commit 062c4ed76a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 66 additions and 67 deletions

View File

@ -53,6 +53,17 @@ Display the main product image.
- **Supports:** - **Supports:**
- **Attributes:** aspectRatio, height, imageSizing, isDescendentOfQueryLoop, isDescendentOfSingleProductBlock, productId, saleBadgeAlign, scale, showProductLink, showSaleBadge, width - **Attributes:** aspectRatio, height, imageSizing, isDescendentOfQueryLoop, isDescendentOfSingleProductBlock, productId, saleBadgeAlign, scale, showProductLink, showSaleBadge, width
## Product Price - woocommerce/product-price
Display the price of a product.
- **Name:** woocommerce/product-price
- **Category:** woocommerce-product-elements
- **Ancestor:** woocommerce/all-products,woocommerce/single-product,woocommerce/product-template,core/post-template
- **Parent:**
- **Supports:** ~~html~~
- **Attributes:** isDescendentOfQueryLoop, isDescendentOfSingleProductBlock, isDescendentOfSingleProductTemplate, productId, textAlign
## Product Details - woocommerce/product-details ## Product Details - woocommerce/product-details
Display a product's description, attributes, and reviews. Display a product's description, attributes, and reviews.

View File

@ -74,7 +74,7 @@
"post_title": "Blocks reference", "post_title": "Blocks reference",
"menu_title": "Blocks Reference", "menu_title": "Blocks Reference",
"edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/building-a-woo-store/block-references.md", "edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/building-a-woo-store/block-references.md",
"hash": "a33fe5766283aaa70154077692a180319110e133ad430bf8dda3032455bad45c", "hash": "329f17097ce67074a915d7814b2363e8b9e908910c1f7b196c8f4fd8594cc55c",
"url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/building-a-woo-store/block-references.md", "url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/building-a-woo-store/block-references.md",
"id": "1fbe91d7fa4fafaf35f0297e4cee1e7958756aed" "id": "1fbe91d7fa4fafaf35f0297e4cee1e7958756aed"
}, },
@ -1804,5 +1804,5 @@
"categories": [] "categories": []
} }
], ],
"hash": "0b0ae9b9ed454ab234a5f053f6efb37bafb3e90f1c98f6488263c019f552697b" "hash": "2ecf48b6181dae0526b3858df889bce4e6ee425e10f2c43d151771d845c5a948"
} }

View File

@ -1,29 +0,0 @@
/**
* External dependencies
*/
import { BlockAttributes } from '@wordpress/blocks';
export const blockAttributes: BlockAttributes = {
productId: {
type: 'number',
default: 0,
},
isDescendentOfQueryLoop: {
type: 'boolean',
default: false,
},
textAlign: {
type: 'string',
default: '',
},
isDescendentOfSingleProductTemplate: {
type: 'boolean',
default: false,
},
isDescendentOfSingleProductBlock: {
type: 'boolean',
default: false,
},
};
export default blockAttributes;

View File

@ -0,0 +1,34 @@
{
"name": "woocommerce/product-price",
"version": "1.0.0",
"title": "Product Price",
"description": "Display the price of a product.",
"category": "woocommerce-product-elements",
"attributes": {
"productId": { "type": "number", "default": 0 },
"isDescendentOfQueryLoop": { "type": "boolean", "default": false },
"textAlign": { "type": "string", "default": "" },
"isDescendentOfSingleProductTemplate": {
"type": "boolean",
"default": false
},
"isDescendentOfSingleProductBlock": {
"type": "boolean",
"default": false
}
},
"usesContext": [ "query", "queryId", "postId" ],
"keywords": [ "WooCommerce" ],
"textdomain": "woocommerce",
"apiVersion": 3,
"supports": {
"html": false
},
"ancestor": [
"woocommerce/all-products",
"woocommerce/single-product",
"woocommerce/product-template",
"core/post-template"
],
"$schema": "https://schemas.wp.org/trunk/block.json"
}

View File

@ -1,17 +0,0 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { currencyDollar, Icon } from '@wordpress/icons';
export const BLOCK_TITLE: string = __( 'Product Price', 'woocommerce' );
export const BLOCK_ICON: JSX.Element = (
<Icon
icon={ currencyDollar }
className="wc-block-editor-components-block-icon"
/>
);
export const BLOCK_DESCRIPTION: string = __(
'Display the price of a product.',
'woocommerce'
);

View File

@ -2,33 +2,29 @@
* External dependencies * External dependencies
*/ */
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils'; import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils';
import { currencyDollar, Icon } from '@wordpress/icons';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import sharedConfig from '../shared/config'; import sharedConfig from '../shared/config';
import edit from './edit'; import edit from './edit';
import attributes from './attributes';
import { supports } from './supports'; import { supports } from './supports';
import { import metadata from './block.json';
BLOCK_TITLE as title,
BLOCK_ICON as icon,
BLOCK_DESCRIPTION as description,
} from './constants';
const blockConfig = {
...sharedConfig,
title,
description,
usesContext: [ 'query', 'queryId', 'postId' ],
icon: { src: icon },
attributes,
supports,
edit,
};
registerBlockSingleProductTemplate( { registerBlockSingleProductTemplate( {
blockName: 'woocommerce/product-price', blockName: metadata.name,
blockSettings: blockConfig, blockMetadata: metadata,
blockSettings: {
...sharedConfig,
supports,
icon: (
<Icon
icon={ currencyDollar }
className="wc-block-editor-components-block-icon"
/>
),
edit,
},
isAvailableOnPostEditor: true, isAvailableOnPostEditor: true,
} ); } );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Product Price: migrate to block.json