Use theme default number of rows

This commit is contained in:
claudiulodro 2018-04-03 10:26:56 -07:00
parent 55054fcd02
commit d5dbda0d9f
3 changed files with 9 additions and 6 deletions

View File

@ -669,7 +669,7 @@ registerBlockType('woocommerce/products', {
*/
rows: {
type: 'number',
default: 1
default: wc_product_block_data.default_rows
},
/**
@ -786,8 +786,8 @@ registerBlockType('woocommerce/products', {
onChange: function onChange(value) {
return setAttributes({ rows: value });
},
min: 1,
max: 6
min: wc_product_block_data.min_rows,
max: wc_product_block_data.max_rows
}),
orderControl
);

View File

@ -414,7 +414,7 @@ registerBlockType( 'woocommerce/products', {
*/
rows: {
type: 'number',
default: 1,
default: wc_product_block_data.default_rows,
},
/**
@ -521,8 +521,8 @@ registerBlockType( 'woocommerce/products', {
label={ __( 'Rows' ) }
value={ rows }
onChange={ ( value ) => setAttributes( { rows: value } ) }
min={ 1 }
max={ 6 }
min={ wc_product_block_data.min_rows }
max={ wc_product_block_data.max_rows }
/>
{ orderControl }
</InspectorControls>

View File

@ -37,6 +37,9 @@ function wgpb_register_products_block() {
'min_columns' => wc_get_theme_support( 'product_grid::min_columns', 1 ),
'max_columns' => wc_get_theme_support( 'product_grid::max_columns', 6 ),
'default_columns' => wc_get_default_products_per_row(),
'min_rows' => wc_get_theme_support( 'product_grid::min_rows', 1 ),
'max_rows' => wc_get_theme_support( 'product_grid::max_rows', 6 ),
'default_rows' => wc_get_default_product_rows_per_page(),
);
wp_localize_script( 'woocommerce-products-block-editor', 'wc_product_block_data', $product_block_data );