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

Commit b1d0715

Browse files
Aljullumikejolley
authored andcommitted
All Products: avoid pagination disappearing when switching pages/changing sort value (#1144)
1 parent dc98a4b commit b1d0715

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

assets/js/base/hooks/use-store-products.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ export const useStoreProducts = ( query ) => {
2727
const collectionOptions = {
2828
namespace: '/wc/store',
2929
resourceName: 'products',
30-
query,
3130
};
3231
const { results: products, isLoading: productsLoading } = useCollection(
33-
collectionOptions
32+
{ ...collectionOptions, query }
3433
);
34+
// eslint-disable-next-line no-unused-vars, camelcase
35+
const { order, orderby, page, per_page, ...totalQuery } = query;
3536
const { value: totalProducts } = useCollectionHeader(
3637
'x-wp-total',
37-
collectionOptions
38+
{ ...collectionOptions, query: totalQuery }
3839
);
3940
return {
4041
products,

0 commit comments

Comments
 (0)