442adcc395
* Remove template matching from front-end * Create 'woocommerce_rest_get_product' filter to allow extensions to change the product when it's fetched through the REST API * Stop defaulting to 'standard-product-template' product template and handle defaults only in getLayoutTemplateId function * Use created hook to determine and persist the product template ID when it's not defined. Also introduce 'match_fn' in ProductTemplate to allow extensions to provide robust ways of matching the template * Add changelog * Fix tests * Remove outdated tests * Fix issue in filter because $product can be false and move API change to v3 * Add comments to continue statements * Small refactor * Only send layout template id to useLayoutTemplate after product is loaded * Revert front-end changes * Remove match_fn and create filter to allow extensions to determine the product template id * Avoid loading layout template before product is loaded * Create woocommerce_product_editor_determine_product_template filter and use it * Update changelogs and remove unused code * Remove _product_template_id for products that were created with the new product editor. * Use only id to find productTemplate * Turn hook into experimental * Remove deprecated tests * Rename filter * Add more typings to useEntityRecord * Use hasResolved boolean to check whether product has been resolved * Add changelog * Add 'variation' to ProductType * Don't default to the standard-product-template for variations * Update changelog * Accept null in getLayoutTemplateId * Fix edit variable product test * Rename hook * Revert changed logic to avoid regressions * Increment useProductTemplate logic * Default to standard-product-template instead of undefined when no matches * Re-import Features class --------- Co-authored-by: Jon Lane <jon.lane@automattic.com> |
||
---|---|---|
.. | ||
changelog | ||
src | ||
typings | ||
.eslintrc.js | ||
.npmrc | ||
CHANGELOG.md | ||
PREVIOUS_CHANGELOG.md | ||
README.md | ||
babel.config.js | ||
composer.json | ||
composer.lock | ||
jest.config.json | ||
package.json | ||
tsconfig-cjs.json | ||
tsconfig.json |
README.md
Data
WooCommerce Admin data store and utilities.
Installation
Install the module
pnpm install @woocommerce/data --save
This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods. Learn more about it in Babel docs.
Usage
import { SETTINGS_STORE_NAME } from '@woocommerce/data';
import { useSelect } from '@wordpress/data';
function MySettings() {
const settings = useSelect( select => {
return select( SETTINGS_STORE_NAME ).getSettings();
} );
return (
<ul>
{ settings.map( setting => (
<li>{ setting.name }</li>
) ) }
</ul>
);
}
// Rendered in the application:
//
// <MySettings />