Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add back filter blocks frontend scripts (#9954)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu authored and thealexandrelara committed Jun 22, 2023
1 parent c4a3253 commit d64fe31
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 27 deletions.
23 changes: 23 additions & 0 deletions assets/js/blocks/attribute-filter/frontend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* External dependencies
*/
import { renderFrontend } from '@woocommerce/base-utils';

/**
* Internal dependencies
*/
import Block from './block';
import { parseAttributes } from './utils';

const getProps = ( el: HTMLElement ) => {
return {
isEditor: false,
attributes: parseAttributes( el.dataset ),
};
};

renderFrontend( {
selector: '.wp-block-woocommerce-attribute-filter',
Block,
getProps,
} );
23 changes: 23 additions & 0 deletions assets/js/blocks/price-filter/frontend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* External dependencies
*/
import { renderFrontend } from '@woocommerce/base-utils';

/**
* Internal dependencies
*/
import Block from './block';
import { parseAttributes } from './utils';

const getProps = ( el: HTMLElement ) => {
return {
attributes: parseAttributes( el.dataset ),
isEditor: false,
};
};

renderFrontend( {
selector: '.wp-block-woocommerce-price-filter',
Block,
getProps,
} );
23 changes: 23 additions & 0 deletions assets/js/blocks/stock-filter/frontend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* External dependencies
*/
import { renderFrontend } from '@woocommerce/base-utils';

/**
* Internal dependencies
*/
import Block from './block';
import { parseAttributes } from './utils';

const getProps = ( el: HTMLElement ) => {
return {
attributes: parseAttributes( el.dataset ),
isEditor: false,
};
};

renderFrontend( {
selector: '.wp-block-woocommerce-stock-filter',
Block,
getProps,
} );
9 changes: 0 additions & 9 deletions src/BlockTypes/AttributeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@ protected function enqueue_data( array $attributes = [] ) {
parent::enqueue_data( $attributes );
$this->asset_data_registry->add( 'attributes', array_values( wc_get_attribute_taxonomies() ), true );
}

/**
* Get the frontend script handle for this block type.
*
* @param string $key Data to get, or default to everything.
*/
protected function get_block_type_script( $key = null ) {
return null;
}
}
9 changes: 0 additions & 9 deletions src/BlockTypes/PriceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,4 @@ class PriceFilter extends AbstractBlock {
protected $block_name = 'price-filter';
const MIN_PRICE_QUERY_VAR = 'min_price';
const MAX_PRICE_QUERY_VAR = 'max_price';

/**
* Get the frontend script handle for this block type.
*
* @param string $key Data to get, or default to everything.
*/
protected function get_block_type_script( $key = null ) {
return null;
}
}
9 changes: 0 additions & 9 deletions src/BlockTypes/StockFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,4 @@ protected function enqueue_data( array $stock_statuses = [] ) {
public static function get_stock_status_query_var_values() {
return array_keys( wc_get_product_stock_status_options() );
}

/**
* Get the frontend script handle for this block type.
*
* @param string $key Data to get, or default to everything.
*/
protected function get_block_type_script( $key = null ) {
return null;
}
}

0 comments on commit d64fe31

Please sign in to comment.