This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Product Rating block: Add Single Product template support to the block (
#9499) * Add Single Product template support to Product Rating block * Remove example attribute from block.json Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Set isDescedentOfSingleProductTemplate attribute default to false * Remove withProductSelector HOC Since we are using the `ancestor` key then we don't need to use this HOC anymore * Remove unused import on Product Rating Edit component --------- Co-authored-by: Luigi Teschio <gigitux@gmail.com>
- Loading branch information
1 parent
6a346fc
commit 45109f4
Showing
5 changed files
with
75 additions
and
56 deletions.
There are no files selected for viewing
25 changes: 0 additions & 25 deletions
25
assets/js/atomic/blocks/product-elements/rating/attributes.ts
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
assets/js/atomic/blocks/product-elements/rating/block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "woocommerce/product-rating", | ||
"version": "1.0.0", | ||
"icon": "info", | ||
"title": "Product Rating", | ||
"description": "Display the average rating of a product.", | ||
"attributes": { | ||
"productId": { | ||
"type": "number", | ||
"default": 0 | ||
}, | ||
"isDescendentOfQueryLoop": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"textAlign": { | ||
"type": "string", | ||
"default": "" | ||
}, | ||
"isDescendentOfSingleProductBlock": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"isDescendentOfSingleProductTemplate": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
}, | ||
"usesContext": [ "query", "queryId", "postId" ], | ||
"category": "woocommerce", | ||
"keywords": [ "WooCommerce" ], | ||
"supports": { | ||
"align": true | ||
}, | ||
"textdomain": "woo-gutenberg-products-block", | ||
"apiVersion": 2, | ||
"$schema": "https://schemas.wp.org/trunk/block.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,33 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
import type { BlockConfiguration } from '@wordpress/blocks'; | ||
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import sharedConfig from '../shared/config'; | ||
import attributes from './attributes'; | ||
import edit from './edit'; | ||
import { | ||
BLOCK_TITLE as title, | ||
BLOCK_ICON as icon, | ||
BLOCK_DESCRIPTION as description, | ||
} from './constants'; | ||
import { BLOCK_ICON as icon } from './constants'; | ||
import metadata from './block.json'; | ||
import { supports } from './support'; | ||
|
||
const blockConfig: BlockConfiguration = { | ||
...sharedConfig, | ||
apiVersion: 2, | ||
title, | ||
description, | ||
usesContext: [ 'query', 'queryId', 'postId' ], | ||
ancestor: [ | ||
'woocommerce/all-products', | ||
'woocommerce/single-product', | ||
'core/post-template', | ||
'woocommerce/product-template', | ||
], | ||
icon: { src: icon }, | ||
attributes, | ||
supports, | ||
edit, | ||
}; | ||
|
||
registerBlockType( 'woocommerce/product-rating', { ...blockConfig } ); | ||
registerBlockSingleProductTemplate( { | ||
blockName: 'woocommerce/product-rating', | ||
blockMetadata: metadata, | ||
blockSettings: blockConfig, | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters