Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439)
* Mass convert all snake case settings keys to camel case * Handling for payment method data props
This commit is contained in:
parent
e0d110ccf0
commit
427fe33af3
|
@ -54,7 +54,7 @@ const Edit = ( {
|
||||||
const blockProps = useBlockProps( { style: { width, height } } );
|
const blockProps = useBlockProps( { style: { width, height } } );
|
||||||
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
||||||
const isBlockThemeEnabled = getSettingWithCoercion(
|
const isBlockThemeEnabled = getSettingWithCoercion(
|
||||||
'is_block_theme_enabled',
|
'isBlockThemeEnabled',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -73,7 +73,7 @@ const ActiveAttributeFilters = ( {
|
||||||
const attributeLabel = attributeObject.label;
|
const attributeLabel = attributeObject.label;
|
||||||
|
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -59,7 +59,7 @@ const ActiveFiltersBlock = ( {
|
||||||
const isMounted = useIsMounted();
|
const isMounted = useIsMounted();
|
||||||
const componentHasMounted = isMounted();
|
const componentHasMounted = isMounted();
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
@ -323,7 +323,7 @@ const ActiveFiltersBlock = ( {
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasFilterableProducts = getSettingWithCoercion(
|
const hasFilterableProducts = getSettingWithCoercion(
|
||||||
'has_filterable_products',
|
'hasFilterableProducts',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -72,19 +72,19 @@ const AttributeFilterBlock = ( {
|
||||||
getNotice?: GetNotice;
|
getNotice?: GetNotice;
|
||||||
} ) => {
|
} ) => {
|
||||||
const hasFilterableProducts = getSettingWithCoercion(
|
const hasFilterableProducts = getSettingWithCoercion(
|
||||||
'has_filterable_products',
|
'hasFilterableProducts',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
||||||
const pageUrl = getSettingWithCoercion(
|
const pageUrl = getSettingWithCoercion(
|
||||||
'page_url',
|
'pageUrl',
|
||||||
window.location.href,
|
window.location.href,
|
||||||
isString
|
isString
|
||||||
);
|
);
|
||||||
|
|
|
@ -42,8 +42,8 @@ export const Edit = ( { attributes, setAttributes }: Props ): JSX.Element => {
|
||||||
onChange={ ( value ) =>
|
onChange={ ( value ) =>
|
||||||
setAttributes( { columns: value } )
|
setAttributes( { columns: value } )
|
||||||
}
|
}
|
||||||
min={ getSetting( 'min_columns', 1 ) }
|
min={ getSetting( 'minColumns', 1 ) }
|
||||||
max={ getSetting( 'max_columns', 6 ) }
|
max={ getSetting( 'maxColumns', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
|
|
|
@ -64,7 +64,7 @@ export function register(
|
||||||
*/
|
*/
|
||||||
minHeight: {
|
minHeight: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_height', 500 ),
|
default: getSetting( 'defaultHeight', 500 ),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
supports: {
|
supports: {
|
||||||
|
@ -100,7 +100,7 @@ export function register(
|
||||||
editMode: false,
|
editMode: false,
|
||||||
hasParallax: false,
|
hasParallax: false,
|
||||||
isRepeated: false,
|
isRepeated: false,
|
||||||
height: getSetting( 'default_height', 500 ),
|
height: getSetting( 'defaultHeight', 500 ),
|
||||||
mediaSrc: '',
|
mediaSrc: '',
|
||||||
overlayColor: '#000000',
|
overlayColor: '#000000',
|
||||||
showDesc: true,
|
showDesc: true,
|
||||||
|
|
|
@ -25,7 +25,7 @@ registerBlockType( metadata, {
|
||||||
...metadata.attributes,
|
...metadata.attributes,
|
||||||
columns: {
|
columns: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_columns', 3 ),
|
default: getSetting( 'defaultColumns', 3 ),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ export const HandpickedProductsInspectorControls = (
|
||||||
onChange={ ( value ) =>
|
onChange={ ( value ) =>
|
||||||
setAttributes( { columns: value } )
|
setAttributes( { columns: value } )
|
||||||
}
|
}
|
||||||
min={ getSetting( 'min_columns', 1 ) }
|
min={ getSetting( 'minColumns', 1 ) }
|
||||||
max={ getSetting( 'max_columns', 6 ) }
|
max={ getSetting( 'maxColumns', 6 ) }
|
||||||
/>
|
/>
|
||||||
<ToggleControl
|
<ToggleControl
|
||||||
label={ __(
|
label={ __(
|
||||||
|
|
|
@ -95,13 +95,13 @@ const PriceFilterBlock = ( {
|
||||||
}: PriceFilterBlockProps ) => {
|
}: PriceFilterBlockProps ) => {
|
||||||
const setWrapperVisibility = useSetWraperVisibility();
|
const setWrapperVisibility = useSetWraperVisibility();
|
||||||
const hasFilterableProducts = getSettingWithCoercion(
|
const hasFilterableProducts = getSettingWithCoercion(
|
||||||
'has_filterable_products',
|
'hasFilterableProducts',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -38,10 +38,10 @@ export const ProductBestSellersInspectorControls = (
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting( 'min_columns', 1 ) }
|
minColumns={ getSetting( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting( 'max_columns', 6 ) }
|
maxColumns={ getSetting( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting( 'min_rows', 1 ) }
|
minRows={ getSetting( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting( 'max_rows', 6 ) }
|
maxRows={ getSetting( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -73,10 +73,10 @@ export const ProductsByCategoryInspectorControls = (
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting( 'min_columns', 1 ) }
|
minColumns={ getSetting( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting( 'max_columns', 6 ) }
|
maxColumns={ getSetting( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting( 'min_rows', 1 ) }
|
minRows={ getSetting( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting( 'max_rows', 6 ) }
|
maxRows={ getSetting( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -46,10 +46,10 @@ export const ProductNewestBlock = ( {
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting( 'min_columns', 1 ) }
|
minColumns={ getSetting( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting( 'max_columns', 6 ) }
|
maxColumns={ getSetting( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting( 'min_rows', 1 ) }
|
minRows={ getSetting( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting( 'max_rows', 6 ) }
|
maxRows={ getSetting( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -47,10 +47,10 @@ export const ProductOnSaleInspectorControls = (
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting< number >( 'min_columns', 1 ) }
|
minColumns={ getSetting< number >( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting< number >( 'max_columns', 6 ) }
|
maxColumns={ getSetting< number >( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting< number >( 'min_rows', 1 ) }
|
minRows={ getSetting< number >( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting< number >( 'max_rows', 6 ) }
|
maxRows={ getSetting< number >( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -76,7 +76,7 @@ export const QUERY_DEFAULT_ATTRIBUTES: QueryBlockAttributes = {
|
||||||
|
|
||||||
// This is necessary to fix https://github.com/woocommerce/woocommerce-blocks/issues/9884.
|
// This is necessary to fix https://github.com/woocommerce/woocommerce-blocks/issues/9884.
|
||||||
const postTemplateHasSupportForGridView = getSettingWithCoercion(
|
const postTemplateHasSupportForGridView = getSettingWithCoercion(
|
||||||
'post_template_has_support_for_grid_view',
|
'postTemplateHasSupportForGridView',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -132,7 +132,7 @@ export const WooInheritToggleControl = (
|
||||||
|
|
||||||
if ( inherit ) {
|
if ( inherit ) {
|
||||||
inheritQuery.perPage = getSettingWithCoercion(
|
inheritQuery.perPage = getSettingWithCoercion(
|
||||||
'loop_shop_per_page',
|
'loopShopPerPage',
|
||||||
12,
|
12,
|
||||||
isNumber
|
isNumber
|
||||||
);
|
);
|
||||||
|
|
|
@ -87,7 +87,7 @@ if ( isWpVersion( '6.1', '>=' ) ) {
|
||||||
|
|
||||||
if ( inherit ) {
|
if ( inherit ) {
|
||||||
inheritQuery.perPage = getSettingWithCoercion(
|
inheritQuery.perPage = getSettingWithCoercion(
|
||||||
'loop_shop_per_page',
|
'loopShopPerPage',
|
||||||
12,
|
12,
|
||||||
isNumber
|
isNumber
|
||||||
);
|
);
|
||||||
|
|
|
@ -46,7 +46,7 @@ export const BLOCK_ATTRIBUTES = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const postTemplateHasSupportForGridView = getSettingWithCoercion(
|
const postTemplateHasSupportForGridView = getSettingWithCoercion(
|
||||||
'post_template_has_support_for_grid_view',
|
'postTemplateHasSupportForGridView',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -109,22 +109,22 @@ const ProductsByTagBlock = ( {
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSettingWithCoercion(
|
minColumns={ getSettingWithCoercion(
|
||||||
'min_columns',
|
'minColumns',
|
||||||
1,
|
1,
|
||||||
isNumber
|
isNumber
|
||||||
) }
|
) }
|
||||||
maxColumns={ getSettingWithCoercion(
|
maxColumns={ getSettingWithCoercion(
|
||||||
'max_columns',
|
'maxColumns',
|
||||||
6,
|
6,
|
||||||
isNumber
|
isNumber
|
||||||
) }
|
) }
|
||||||
minRows={ getSettingWithCoercion(
|
minRows={ getSettingWithCoercion(
|
||||||
'min_rows',
|
'minRows',
|
||||||
6,
|
6,
|
||||||
isNumber
|
isNumber
|
||||||
) }
|
) }
|
||||||
maxRows={ getSettingWithCoercion(
|
maxRows={ getSettingWithCoercion(
|
||||||
'max_rows',
|
'maxRows',
|
||||||
6,
|
6,
|
||||||
isNumber
|
isNumber
|
||||||
) }
|
) }
|
||||||
|
|
|
@ -28,11 +28,11 @@ registerBlockType( metadata, {
|
||||||
...metadata.attributes,
|
...metadata.attributes,
|
||||||
columns: {
|
columns: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_columns', 3 ),
|
default: getSetting( 'defaultColumns', 3 ),
|
||||||
},
|
},
|
||||||
rows: {
|
rows: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_rows', 3 ),
|
default: getSetting( 'defaultRows', 3 ),
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
|
|
|
@ -105,7 +105,7 @@ const ProductTemplateEdit = ( {
|
||||||
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
|
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
|
||||||
const postType = 'product';
|
const postType = 'product';
|
||||||
const loopShopPerPage = getSettingWithCoercion(
|
const loopShopPerPage = getSettingWithCoercion(
|
||||||
'loop_shop_per_page',
|
'loopShopPerPage',
|
||||||
12,
|
12,
|
||||||
isNumber
|
isNumber
|
||||||
);
|
);
|
||||||
|
|
|
@ -47,10 +47,10 @@ export const ProductTopRatedBlock = ( {
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting( 'min_columns', 1 ) }
|
minColumns={ getSetting( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting( 'max_columns', 6 ) }
|
maxColumns={ getSetting( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting( 'min_rows', 1 ) }
|
minRows={ getSetting( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting( 'max_rows', 6 ) }
|
maxRows={ getSetting( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -25,11 +25,11 @@ registerBlockType( metadata, {
|
||||||
...metadata.attributes,
|
...metadata.attributes,
|
||||||
columns: {
|
columns: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_columns', 3 ),
|
default: getSetting( 'defaultColumns', 3 ),
|
||||||
},
|
},
|
||||||
rows: {
|
rows: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_rows', 3 ),
|
default: getSetting( 'defaultRows', 3 ),
|
||||||
},
|
},
|
||||||
stockStatus: {
|
stockStatus: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
|
|
|
@ -42,10 +42,10 @@ export const ProductsByAttributeInspectorControls = (
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting( 'min_columns', 1 ) }
|
minColumns={ getSetting( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting( 'max_columns', 6 ) }
|
maxColumns={ getSetting( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting( 'min_rows', 1 ) }
|
minRows={ getSetting( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting( 'max_rows', 6 ) }
|
maxRows={ getSetting( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -9,8 +9,8 @@ import { getSetting } from '@woocommerce/settings';
|
||||||
import { DEFAULT_PRODUCT_LIST_LAYOUT } from '../base-utils';
|
import { DEFAULT_PRODUCT_LIST_LAYOUT } from '../base-utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
columns: getSetting( 'default_columns', 3 ),
|
columns: getSetting( 'defaultColumns', 3 ),
|
||||||
rows: getSetting( 'default_rows', 3 ),
|
rows: getSetting( 'defaultRows', 3 ),
|
||||||
alignButtons: false,
|
alignButtons: false,
|
||||||
contentVisibility: {
|
contentVisibility: {
|
||||||
orderBy: true,
|
orderBy: true,
|
||||||
|
|
|
@ -120,10 +120,10 @@ class Editor extends Component {
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
alignButtons={ alignButtons }
|
alignButtons={ alignButtons }
|
||||||
setAttributes={ setAttributes }
|
setAttributes={ setAttributes }
|
||||||
minColumns={ getSetting( 'min_columns', 1 ) }
|
minColumns={ getSetting( 'minColumns', 1 ) }
|
||||||
maxColumns={ getSetting( 'max_columns', 6 ) }
|
maxColumns={ getSetting( 'maxColumns', 6 ) }
|
||||||
minRows={ getSetting( 'min_rows', 1 ) }
|
minRows={ getSetting( 'minRows', 1 ) }
|
||||||
maxRows={ getSetting( 'max_rows', 6 ) }
|
maxRows={ getSetting( 'maxRows', 6 ) }
|
||||||
/>
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
|
@ -73,7 +73,7 @@ const RatingFilterBlock = ( {
|
||||||
const setWrapperVisibility = useSetWraperVisibility();
|
const setWrapperVisibility = useSetWraperVisibility();
|
||||||
|
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
@ -312,7 +312,7 @@ const RatingFilterBlock = ( {
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasFilterableProducts = getSettingWithCoercion(
|
const hasFilterableProducts = getSettingWithCoercion(
|
||||||
'has_filterable_products',
|
'hasFilterableProducts',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -73,7 +73,7 @@ const checkIfBlockCanBeInserted = (
|
||||||
};
|
};
|
||||||
|
|
||||||
const postTemplateHasSupportForGridView = getSettingWithCoercion(
|
const postTemplateHasSupportForGridView = getSettingWithCoercion(
|
||||||
'post_template_has_support_for_grid_view',
|
'postTemplateHasSupportForGridView',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,7 +63,7 @@ const StockStatusFilterBlock = ( {
|
||||||
const setWrapperVisibility = useSetWraperVisibility();
|
const setWrapperVisibility = useSetWraperVisibility();
|
||||||
|
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
@ -412,7 +412,7 @@ const StockStatusFilterBlock = ( {
|
||||||
const isDisabled = ! blockAttributes.isPreview && filteredCountsLoading;
|
const isDisabled = ! blockAttributes.isPreview && filteredCountsLoading;
|
||||||
|
|
||||||
const hasFilterableProducts = getSettingWithCoercion(
|
const hasFilterableProducts = getSettingWithCoercion(
|
||||||
'has_filterable_products',
|
'hasFilterableProducts',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,7 +43,7 @@ jest.mock( '@woocommerce/settings', () => {
|
||||||
getSettingWithCoercion: jest
|
getSettingWithCoercion: jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockImplementation( ( key, defaultValue ) => {
|
.mockImplementation( ( key, defaultValue ) => {
|
||||||
if ( key === 'has_filterable_products' ) {
|
if ( key === 'hasFilterableProducts' ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
|
@ -175,7 +175,7 @@ export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
||||||
? Object.keys( paymentMethods )
|
? Object.keys( paymentMethods )
|
||||||
: Array.from(
|
: Array.from(
|
||||||
new Set( [
|
new Set( [
|
||||||
...( getSetting( 'paymentGatewaySortOrder', [] ) as [] ),
|
...( getSetting( 'paymentMethodSortOrder', [] ) as [] ),
|
||||||
...Object.keys( paymentMethods ),
|
...Object.keys( paymentMethods ),
|
||||||
] )
|
] )
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { getSetting } from '@woocommerce/settings';
|
import { getPaymentMethodData } from '@woocommerce/settings';
|
||||||
import { decodeEntities } from '@wordpress/html-entities';
|
import { decodeEntities } from '@wordpress/html-entities';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,12 +11,12 @@ import { decodeEntities } from '@wordpress/html-entities';
|
||||||
*/
|
*/
|
||||||
import { PAYMENT_METHOD_NAME } from './constants';
|
import { PAYMENT_METHOD_NAME } from './constants';
|
||||||
|
|
||||||
const settings = getSetting( 'bacs_data', {} );
|
const settings = getPaymentMethodData( 'bacs', {} );
|
||||||
const defaultLabel = __(
|
const defaultLabel = __(
|
||||||
'Direct bank transfer',
|
'Direct bank transfer',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
);
|
);
|
||||||
const label = decodeEntities( settings.title ) || defaultLabel;
|
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content component
|
* Content component
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { getSetting } from '@woocommerce/settings';
|
import { getPaymentMethodData } from '@woocommerce/settings';
|
||||||
import { decodeEntities } from '@wordpress/html-entities';
|
import { decodeEntities } from '@wordpress/html-entities';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,9 +11,9 @@ import { decodeEntities } from '@wordpress/html-entities';
|
||||||
*/
|
*/
|
||||||
import { PAYMENT_METHOD_NAME } from './constants';
|
import { PAYMENT_METHOD_NAME } from './constants';
|
||||||
|
|
||||||
const settings = getSetting( 'cheque_data', {} );
|
const settings = getPaymentMethodData( 'cheque', {} );
|
||||||
const defaultLabel = __( 'Check payment', 'woo-gutenberg-products-block' );
|
const defaultLabel = __( 'Check payment', 'woo-gutenberg-products-block' );
|
||||||
const label = decodeEntities( settings.title ) || defaultLabel;
|
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content component
|
* Content component
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { getSetting } from '@woocommerce/settings';
|
import { getPaymentMethodData } from '@woocommerce/settings';
|
||||||
import { decodeEntities } from '@wordpress/html-entities';
|
import { decodeEntities } from '@wordpress/html-entities';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,9 +11,9 @@ import { decodeEntities } from '@wordpress/html-entities';
|
||||||
*/
|
*/
|
||||||
import { PAYMENT_METHOD_NAME } from './constants';
|
import { PAYMENT_METHOD_NAME } from './constants';
|
||||||
|
|
||||||
const settings = getSetting( 'cod_data', {} );
|
const settings = getPaymentMethodData( 'cod', {} );
|
||||||
const defaultLabel = __( 'Cash on delivery', 'woo-gutenberg-products-block' );
|
const defaultLabel = __( 'Cash on delivery', 'woo-gutenberg-products-block' );
|
||||||
const label = decodeEntities( settings.title ) || defaultLabel;
|
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content component
|
* Content component
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { getSetting, WC_ASSET_URL } from '@woocommerce/settings';
|
import { getPaymentMethodData, WC_ASSET_URL } from '@woocommerce/settings';
|
||||||
import { decodeEntities } from '@wordpress/html-entities';
|
import { decodeEntities } from '@wordpress/html-entities';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ import { decodeEntities } from '@wordpress/html-entities';
|
||||||
*/
|
*/
|
||||||
import { PAYMENT_METHOD_NAME } from './constants';
|
import { PAYMENT_METHOD_NAME } from './constants';
|
||||||
|
|
||||||
const settings = getSetting( 'paypal_data', {} );
|
const settings = getPaymentMethodData( 'paypal', {} );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content component
|
* Content component
|
||||||
|
@ -38,7 +38,7 @@ const paypalPaymentMethod = {
|
||||||
edit: <Content />,
|
edit: <Content />,
|
||||||
canMakePayment: () => true,
|
canMakePayment: () => true,
|
||||||
ariaLabel: decodeEntities(
|
ariaLabel: decodeEntities(
|
||||||
settings.title ||
|
settings?.title ||
|
||||||
__( 'Payment via PayPal', 'woo-gutenberg-products-block' )
|
__( 'Payment via PayPal', 'woo-gutenberg-products-block' )
|
||||||
),
|
),
|
||||||
supports: {
|
supports: {
|
||||||
|
|
|
@ -21,7 +21,25 @@ export const getSetting = < T >(
|
||||||
filter = ( val: unknown, fb: unknown ) =>
|
filter = ( val: unknown, fb: unknown ) =>
|
||||||
typeof val !== 'undefined' ? val : fb
|
typeof val !== 'undefined' ? val : fb
|
||||||
): T => {
|
): T => {
|
||||||
const value = name in allSettings ? allSettings[ name ] : fallback;
|
let value = fallback;
|
||||||
|
|
||||||
|
if ( name in allSettings ) {
|
||||||
|
value = allSettings[ name ];
|
||||||
|
} else if ( name.includes( '_data' ) ) {
|
||||||
|
// This handles back compat with payment data _data properties after the move to camelCase and the dedicated
|
||||||
|
// paymentMethodData setting.
|
||||||
|
const nameWithoutData = name.replace( '_data', '' );
|
||||||
|
const paymentMethodData = getSetting(
|
||||||
|
'paymentMethodData',
|
||||||
|
{}
|
||||||
|
) as Record< string, unknown >;
|
||||||
|
|
||||||
|
value =
|
||||||
|
nameWithoutData in paymentMethodData
|
||||||
|
? paymentMethodData[ nameWithoutData ]
|
||||||
|
: fallback;
|
||||||
|
}
|
||||||
|
|
||||||
return filter( value, fallback ) as T;
|
return filter( value, fallback ) as T;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,3 +124,17 @@ export const isWcVersion = (
|
||||||
*/
|
*/
|
||||||
export const getAdminLink = ( path: string ): string =>
|
export const getAdminLink = ( path: string ): string =>
|
||||||
getSetting( 'adminUrl' ) + path;
|
getSetting( 'adminUrl' ) + path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get payment method data from the paymentMethodData setting.
|
||||||
|
*/
|
||||||
|
export const getPaymentMethodData = (
|
||||||
|
paymentMethodId: string,
|
||||||
|
defaultValue: null | unknown = null
|
||||||
|
) => {
|
||||||
|
const paymentMethodData = getSetting( 'paymentMethodData', {} ) as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
>;
|
||||||
|
return paymentMethodData[ paymentMethodId ] ?? defaultValue;
|
||||||
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { getSettingWithCoercion } from '@woocommerce/settings';
|
||||||
import { isBoolean } from '@woocommerce/types';
|
import { isBoolean } from '@woocommerce/types';
|
||||||
|
|
||||||
const filteringForPhpTemplate = getSettingWithCoercion(
|
const filteringForPhpTemplate = getSettingWithCoercion(
|
||||||
'is_rendering_php_template',
|
'isRenderingPhpTemplate',
|
||||||
false,
|
false,
|
||||||
isBoolean
|
isBoolean
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default {
|
||||||
*/
|
*/
|
||||||
columns: {
|
columns: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_columns', 3 ),
|
default: getSetting( 'defaultColumns', 3 ),
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ export default {
|
||||||
*/
|
*/
|
||||||
rows: {
|
rows: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: getSetting( 'default_rows', 3 ),
|
default: getSetting( 'defaultRows', 3 ),
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -293,9 +293,9 @@ class AssetDataRegistry {
|
||||||
* You can only register data that is not already in the registry identified by the given key. If there is a
|
* You can only register data that is not already in the registry identified by the given key. If there is a
|
||||||
* duplicate found, unless $ignore_duplicates is true, an exception will be thrown.
|
* duplicate found, unless $ignore_duplicates is true, an exception will be thrown.
|
||||||
*
|
*
|
||||||
* @param string $key The key used to reference the data being registered.
|
* @param string $key The key used to reference the data being registered. This should use camelCase.
|
||||||
* @param mixed $data If not a function, registered to the registry as is. If a function, then the
|
* @param mixed $data If not a function, registered to the registry as is. If a function, then the
|
||||||
* callback is invoked right before output to the screen.
|
* callback is invoked right before output to the screen.
|
||||||
* @param boolean $check_key_exists If set to true, duplicate data will be ignored if the key exists.
|
* @param boolean $check_key_exists If set to true, duplicate data will be ignored if the key exists.
|
||||||
* If false, duplicate data will cause an exception.
|
* If false, duplicate data will cause an exception.
|
||||||
*
|
*
|
||||||
|
|
|
@ -678,13 +678,12 @@ abstract class AbstractProductGrid extends AbstractDynamicBlock {
|
||||||
*/
|
*/
|
||||||
protected function enqueue_data( array $attributes = [] ) {
|
protected function enqueue_data( array $attributes = [] ) {
|
||||||
parent::enqueue_data( $attributes );
|
parent::enqueue_data( $attributes );
|
||||||
$this->asset_data_registry->add( 'min_columns', wc_get_theme_support( 'product_blocks::min_columns', 1 ), true );
|
$this->asset_data_registry->add( 'minColumns', wc_get_theme_support( 'product_blocks::min_columns', 1 ), true );
|
||||||
$this->asset_data_registry->add( 'max_columns', wc_get_theme_support( 'product_blocks::max_columns', 6 ), true );
|
$this->asset_data_registry->add( 'maxColumns', wc_get_theme_support( 'product_blocks::max_columns', 6 ), true );
|
||||||
$this->asset_data_registry->add( 'default_columns', wc_get_theme_support( 'product_blocks::default_columns', 3 ), true );
|
$this->asset_data_registry->add( 'defaultColumns', wc_get_theme_support( 'product_blocks::default_columns', 3 ), true );
|
||||||
$this->asset_data_registry->add( 'min_rows', wc_get_theme_support( 'product_blocks::min_rows', 1 ), true );
|
$this->asset_data_registry->add( 'minRows', wc_get_theme_support( 'product_blocks::min_rows', 1 ), true );
|
||||||
$this->asset_data_registry->add( 'max_rows', wc_get_theme_support( 'product_blocks::max_rows', 6 ), true );
|
$this->asset_data_registry->add( 'maxRows', wc_get_theme_support( 'product_blocks::max_rows', 6 ), true );
|
||||||
$this->asset_data_registry->add( 'default_rows', wc_get_theme_support( 'product_blocks::default_rows', 3 ), true );
|
$this->asset_data_registry->add( 'defaultRows', wc_get_theme_support( 'product_blocks::default_rows', 3 ), true );
|
||||||
$this->asset_data_registry->add( 'stock_status_options', wc_get_product_stock_status_options(), true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,14 +22,13 @@ class AllProducts extends AbstractBlock {
|
||||||
protected function enqueue_data( array $attributes = [] ) {
|
protected function enqueue_data( array $attributes = [] ) {
|
||||||
parent::enqueue_data( $attributes );
|
parent::enqueue_data( $attributes );
|
||||||
// Set this so filter blocks being used as widgets know when to render.
|
// Set this so filter blocks being used as widgets know when to render.
|
||||||
$this->asset_data_registry->add( 'has_filterable_products', true, true );
|
$this->asset_data_registry->add( 'hasFilterableProducts', true, true );
|
||||||
|
$this->asset_data_registry->add( 'minColumns', wc_get_theme_support( 'product_blocks::min_columns', 1 ), true );
|
||||||
$this->asset_data_registry->add( 'min_columns', wc_get_theme_support( 'product_blocks::min_columns', 1 ), true );
|
$this->asset_data_registry->add( 'maxColumns', wc_get_theme_support( 'product_blocks::max_columns', 6 ), true );
|
||||||
$this->asset_data_registry->add( 'max_columns', wc_get_theme_support( 'product_blocks::max_columns', 6 ), true );
|
$this->asset_data_registry->add( 'defaultColumns', wc_get_theme_support( 'product_blocks::default_columns', 3 ), true );
|
||||||
$this->asset_data_registry->add( 'default_columns', wc_get_theme_support( 'product_blocks::default_columns', 3 ), true );
|
$this->asset_data_registry->add( 'minRows', wc_get_theme_support( 'product_blocks::min_rows', 1 ), true );
|
||||||
$this->asset_data_registry->add( 'min_rows', wc_get_theme_support( 'product_blocks::min_rows', 1 ), true );
|
$this->asset_data_registry->add( 'maxRows', wc_get_theme_support( 'product_blocks::max_rows', 6 ), true );
|
||||||
$this->asset_data_registry->add( 'max_rows', wc_get_theme_support( 'product_blocks::max_rows', 6 ), true );
|
$this->asset_data_registry->add( 'defaultRows', wc_get_theme_support( 'product_blocks::default_rows', 3 ), true );
|
||||||
$this->asset_data_registry->add( 'default_rows', wc_get_theme_support( 'product_blocks::default_rows', 3 ), true );
|
|
||||||
|
|
||||||
// Hydrate the All Product block with data from the API. This is for the add to cart buttons which show current quantity in cart, and events.
|
// Hydrate the All Product block with data from the API. This is for the add to cart buttons which show current quantity in cart, and events.
|
||||||
if ( ! is_admin() && ! WC()->is_rest_api_request() ) {
|
if ( ! is_admin() && ! WC()->is_rest_api_request() ) {
|
||||||
|
|
|
@ -105,13 +105,13 @@ class ClassicTemplate extends AbstractDynamicBlock {
|
||||||
|
|
||||||
if ( in_array( $attributes['template'], $archive_templates, true ) ) {
|
if ( in_array( $attributes['template'], $archive_templates, true ) ) {
|
||||||
// Set this so that our product filters can detect if it's a PHP template.
|
// Set this so that our product filters can detect if it's a PHP template.
|
||||||
$this->asset_data_registry->add( 'is_rendering_php_template', true, true );
|
$this->asset_data_registry->add( 'isRenderingPhpTemplate', true, true );
|
||||||
|
|
||||||
// Set this so filter blocks being used as widgets know when to render.
|
// Set this so filter blocks being used as widgets know when to render.
|
||||||
$this->asset_data_registry->add( 'has_filterable_products', true, true );
|
$this->asset_data_registry->add( 'hasFilterableProducts', true, true );
|
||||||
|
|
||||||
$this->asset_data_registry->add(
|
$this->asset_data_registry->add(
|
||||||
'page_url',
|
'pageUrl',
|
||||||
html_entity_decode( get_pagenum_link() ),
|
html_entity_decode( get_pagenum_link() ),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
|
@ -321,7 +321,6 @@ abstract class FeaturedItem extends AbstractDynamicBlock {
|
||||||
*/
|
*/
|
||||||
protected function enqueue_data( array $attributes = [] ) {
|
protected function enqueue_data( array $attributes = [] ) {
|
||||||
parent::enqueue_data( $attributes );
|
parent::enqueue_data( $attributes );
|
||||||
$this->asset_data_registry->add( 'min_height', wc_get_theme_support( 'featured_block::min_height', 500 ), true );
|
$this->asset_data_registry->add( 'defaultHeight', wc_get_theme_support( 'featured_block::default_height', 500 ), true );
|
||||||
$this->asset_data_registry->add( 'default_height', wc_get_theme_support( 'featured_block::default_height', 500 ), true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ class ProductCollection extends AbstractBlock {
|
||||||
|
|
||||||
// The `loop_shop_per_page` filter can be found in WC_Query::product_query().
|
// The `loop_shop_per_page` filter can be found in WC_Query::product_query().
|
||||||
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||||
$this->asset_data_registry->add( 'loop_shop_per_page', apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ), true );
|
$this->asset_data_registry->add( 'loopShopPerPage', apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ), true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,12 +150,12 @@ class ProductCollection extends AbstractBlock {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->asset_data_registry->add( 'has_filterable_products', true, true );
|
$this->asset_data_registry->add( 'hasFilterableProducts', true, true );
|
||||||
/**
|
/**
|
||||||
* It enables the page to refresh when a filter is applied, ensuring that the product collection block,
|
* It enables the page to refresh when a filter is applied, ensuring that the product collection block,
|
||||||
* which is a server-side rendered (SSR) block, retrieves the products that match the filters.
|
* which is a server-side rendered (SSR) block, retrieves the products that match the filters.
|
||||||
*/
|
*/
|
||||||
$this->asset_data_registry->add( 'is_rendering_php_template', true, true );
|
$this->asset_data_registry->add( 'isRenderingPhpTemplate', true, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -190,7 +190,7 @@ class ProductImage extends AbstractBlock {
|
||||||
* not in the post content on editor load.
|
* not in the post content on editor load.
|
||||||
*/
|
*/
|
||||||
protected function enqueue_data( array $attributes = [] ) {
|
protected function enqueue_data( array $attributes = [] ) {
|
||||||
$this->asset_data_registry->add( 'is_block_theme_enabled', wc_current_theme_is_fse_theme(), false );
|
$this->asset_data_registry->add( 'isBlockThemeEnabled', wc_current_theme_is_fse_theme(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -202,13 +202,13 @@ class ProductQuery extends AbstractBlock {
|
||||||
$post_template_has_support_for_grid_view = $this->check_if_post_template_has_support_for_grid_view();
|
$post_template_has_support_for_grid_view = $this->check_if_post_template_has_support_for_grid_view();
|
||||||
|
|
||||||
$this->asset_data_registry->add(
|
$this->asset_data_registry->add(
|
||||||
'post_template_has_support_for_grid_view',
|
'postTemplateHasSupportForGridView',
|
||||||
$post_template_has_support_for_grid_view
|
$post_template_has_support_for_grid_view
|
||||||
);
|
);
|
||||||
|
|
||||||
// The `loop_shop_per_page` filter can be found in WC_Query::product_query().
|
// The `loop_shop_per_page` filter can be found in WC_Query::product_query().
|
||||||
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||||
$this->asset_data_registry->add( 'loop_shop_per_page', apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ), true );
|
$this->asset_data_registry->add( 'loopShopPerPage', apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ), true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,8 +253,8 @@ class ProductQuery extends AbstractBlock {
|
||||||
|
|
||||||
if ( self::is_woocommerce_variation( $parsed_block ) ) {
|
if ( self::is_woocommerce_variation( $parsed_block ) ) {
|
||||||
// Set this so that our product filters can detect if it's a PHP template.
|
// Set this so that our product filters can detect if it's a PHP template.
|
||||||
$this->asset_data_registry->add( 'has_filterable_products', true, true );
|
$this->asset_data_registry->add( 'hasFilterableProducts', true, true );
|
||||||
$this->asset_data_registry->add( 'is_rendering_php_template', true, true );
|
$this->asset_data_registry->add( 'isRenderingPhpTemplate', true, true );
|
||||||
add_filter(
|
add_filter(
|
||||||
'query_loop_block_query_vars',
|
'query_loop_block_query_vars',
|
||||||
array( $this, 'build_query' ),
|
array( $this, 'build_query' ),
|
||||||
|
|
|
@ -80,13 +80,13 @@ class Api {
|
||||||
* Add payment method data to Asset Registry.
|
* Add payment method data to Asset Registry.
|
||||||
*/
|
*/
|
||||||
public function add_payment_method_script_data() {
|
public function add_payment_method_script_data() {
|
||||||
// Enqueue the order of enabled gateways as `paymentGatewaySortOrder`.
|
// Enqueue the order of enabled gateways.
|
||||||
if ( ! $this->asset_registry->exists( 'paymentGatewaySortOrder' ) ) {
|
if ( ! $this->asset_registry->exists( 'paymentMethodSortOrder' ) ) {
|
||||||
// We use payment_gateways() here to get the sort order of all enabled gateways. Some may be
|
// We use payment_gateways() here to get the sort order of all enabled gateways. Some may be
|
||||||
// programmatically disabled later on, but we still need to know where the enabled ones are in the list.
|
// programmatically disabled later on, but we still need to know where the enabled ones are in the list.
|
||||||
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
||||||
$enabled_gateways = array_filter( $payment_gateways, array( $this, 'is_payment_gateway_enabled' ) );
|
$enabled_gateways = array_filter( $payment_gateways, array( $this, 'is_payment_gateway_enabled' ) );
|
||||||
$this->asset_registry->add( 'paymentGatewaySortOrder', array_keys( $enabled_gateways ) );
|
$this->asset_registry->add( 'paymentMethodSortOrder', array_keys( $enabled_gateways ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enqueue all registered gateway data (settings/config etc).
|
// Enqueue all registered gateway data (settings/config etc).
|
||||||
|
|
|
@ -59,9 +59,9 @@ final class PaymentMethodRegistry extends IntegrationRegistry {
|
||||||
$payment_methods = $this->get_all_active_registered();
|
$payment_methods = $this->get_all_active_registered();
|
||||||
|
|
||||||
foreach ( $payment_methods as $payment_method ) {
|
foreach ( $payment_methods as $payment_method ) {
|
||||||
$script_data[ $payment_method->get_name() . '_data' ] = $payment_method->get_payment_method_data();
|
$script_data[ $payment_method->get_name() ] = $payment_method->get_payment_method_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_filter( $script_data );
|
return array( 'paymentMethodData' => array_filter( $script_data ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class ClassicTemplatesCompatibility {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
|
|
||||||
if ( is_shop() || is_product_taxonomy() || 'widgets.php' === $pagenow ) {
|
if ( is_shop() || is_product_taxonomy() || 'widgets.php' === $pagenow ) {
|
||||||
$this->asset_data_registry->add( 'has_filterable_products', true, true );
|
$this->asset_data_registry->add( 'hasFilterableProducts', true, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class ClassicTemplatesCompatibility {
|
||||||
*/
|
*/
|
||||||
public function set_php_template_data() {
|
public function set_php_template_data() {
|
||||||
if ( is_shop() || is_product_taxonomy() ) {
|
if ( is_shop() || is_product_taxonomy() ) {
|
||||||
$this->asset_data_registry->add( 'is_rendering_php_template', true, true );
|
$this->asset_data_registry->add( 'isRenderingPhpTemplate', true, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ global.wcSettings = {
|
||||||
date: {
|
date: {
|
||||||
dow: 0,
|
dow: 0,
|
||||||
},
|
},
|
||||||
has_filterable_products: true,
|
hasFilterableProducts: true,
|
||||||
orderStatuses: {
|
orderStatuses: {
|
||||||
pending: 'Pending payment',
|
pending: 'Pending payment',
|
||||||
processing: 'Processing',
|
processing: 'Processing',
|
||||||
|
|
Loading…
Reference in New Issue