This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Filter Products by Stock block compatible with PHP rendered Clas…
…sic Template block (#6261) * Enable Attribute Filter block to work with the PHP rendered Classic Template block * Check for presence of option before rendering it * improve filter product by attribute * fix pagination problem * fix check when two filter block with same attribute are used * fix filter by stock for PHP templates * fix naming and comment * Update filter key in ClassicTemplate * Update stock filter block for PHP templates when the filter button is enabled * Remove unused useEffect and fix ESLint error * Set active stock filter and track using local state * ESLint fix * Remove unncessary dependencies from useEffect Co-authored-by: tjcafferkey <[email protected]>
- Loading branch information
1 parent
e079f26
commit 3dba53c
Showing
10 changed files
with
207 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isString } from '@woocommerce/types'; | ||
import { getUrlParameter } from '@woocommerce/utils'; | ||
|
||
export const getActiveFilters = ( | ||
filters: Record< string, string >, | ||
queryParamKey: 'filter_stock_status' | ||
) => { | ||
const params = getUrlParameter( queryParamKey ); | ||
|
||
if ( ! params ) { | ||
return []; | ||
} | ||
|
||
const parsedParams = isString( params ) ? params.split( ',' ) : params; | ||
|
||
return Object.keys( filters ).filter( ( filter ) => | ||
parsedParams.includes( filter ) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export * from './attributes-query'; | ||
export * from './attributes'; | ||
export * from './filters'; | ||
export * from './global-style'; | ||
export * from './notices'; | ||
export * from './products'; | ||
export * from './shared-attributes'; | ||
export * from './useThrottle'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters