Format prices in preview

This commit is contained in:
claudiulodro 2018-03-09 11:45:53 -08:00
parent 8dbc87ee37
commit 52c6b37abf
3 changed files with 10 additions and 15 deletions

View File

@ -538,11 +538,7 @@ var ProductPreview = function (_React$Component4) {
{ className: 'product-title' },
product.name
),
wp.element.createElement(
'div',
{ className: 'product-price' },
product.price
),
wp.element.createElement('div', { className: 'product-price', dangerouslySetInnerHTML: { __html: product.price_html } }),
wp.element.createElement(
'span',
{ className: 'product-add-to-cart' },
@ -670,7 +666,7 @@ registerBlockType('woocommerce/products', {
*/
columns: {
type: 'number',
default: wc_theme_column_settings.default_columns
default: wc_product_block_data.default_columns
},
/**
@ -739,8 +735,8 @@ registerBlockType('woocommerce/products', {
onChange: function onChange(value) {
return setAttributes({ columns: value });
},
min: wc_theme_column_settings.min_columns,
max: wc_theme_column_settings.max_columns
min: wc_product_block_data.min_columns,
max: wc_product_block_data.max_columns
});
}

View File

@ -319,7 +319,7 @@ class ProductPreview extends React.Component {
<div className="product-preview">
{ image }
<div className="product-title">{ product.name }</div>
<div className="product-price">{ product.price }</div>
<div className="product-price" dangerouslySetInnerHTML={ { __html: product.price_html } } />
<span className="product-add-to-cart">{ __( 'Add to cart' ) }</span>
</div>
);
@ -411,7 +411,7 @@ registerBlockType( 'woocommerce/products', {
*/
columns: {
type: 'number',
default: wc_theme_column_settings.default_columns,
default: wc_product_block_data.default_columns,
},
/**
@ -469,8 +469,8 @@ registerBlockType( 'woocommerce/products', {
label={ __( 'Columns' ) }
value={ columns }
onChange={ ( value ) => setAttributes( { columns: value } ) }
min={ wc_theme_column_settings.min_columns }
max={ wc_theme_column_settings.max_columns }
min={ wc_product_block_data.min_columns }
max={ wc_product_block_data.max_columns }
/>
);
}

View File

@ -33,13 +33,12 @@ function wgpb_register_products_block() {
rand() // @todo Change this to WC_VERSION when merged into WooCommerce.
);
// Make the theme's column settings available.
$column_data = array(
$product_block_data = array(
'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(),
);
wp_localize_script( 'woocommerce-products-block-editor', 'wc_theme_column_settings', $column_data );
wp_localize_script( 'woocommerce-products-block-editor', 'wc_product_block_data', $product_block_data );
wp_register_style(
'woocommerce-products-block-editor',