Skip to content

Commit

Permalink
add sponsoredCount-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
hiagolcm committed Nov 29, 2024
1 parent a5da064 commit 2b61ef8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Removed
- `sponsoredProductsBehavior` prop which is deprecated

### Added

- `sponsoredCount` prop
- Shipping filter on filters section

### Fixed
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Check all props to configure your search data in the table below:
| `installmentCriteria` | `enum` | Defines which price should be displayed when different installments are available. Possible values are: `MAX_WITHOUT_INTEREST` (displays the maximum installment option with no interest attached to it) or `MAX_WITH_INTEREST` (displays the maximum installment option whether it has interest attached to it or not). | `"MAX_WITHOUT_INTEREST"` |
| `excludedPaymentSystems` | `string` | List of payment systems that should not be considered when displaying the installment options to users. This prop configuration only works if the `installmentCriteria` prop was also declared. In case it was not, all available payment systems will be displayed regardless. | `undefined` |
| `includedPaymentSystems` | `string` | List of payment systems that should be considered when displaying the installment options to users. This prop configuration only works if the `installmentCriteria` prop was also declared. In case it was not, all available payment systems will be displayed regardless.| `undefined` |
| `sponsoredCount` | `number` | Maximum amount of sponsored products.| `3` |

> ℹ️ Pagination does not display results after page 50. You can configure it to display more products per page using the prop `maxItemsPerPage` by increasing the quantity of products on each page.
Expand Down
8 changes: 4 additions & 4 deletions react/components/SearchQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const useCorrectSearchStateVariables = (
return result
}

const useQueries = (variables, facetsArgs, price) => {
const useQueries = (variables, facetsArgs, price, sponsoredCount) => {
const { getSettings, query: runtimeQuery } = useRuntime()

const settings = getSettings('vtex.store')
Expand All @@ -157,7 +157,7 @@ const useQueries = (variables, facetsArgs, price) => {
variant: getCookie('sp-variant'),
advertisementOptions: {
showSponsored: true,
sponsoredCount: 3,
sponsoredCount,
advertisementPlacement: 'top_search',
repeatSponsoredProducts: true,
},
Expand Down Expand Up @@ -282,7 +282,7 @@ const SearchQuery = ({
searchState: searchStateQuery,
lazyItemsQuery: lazyItemsQueryProp,
__unstableProductOriginVtex,
sponsoredProductsBehavior,
sponsoredCount = 3,
}) => {
const [selectedFacets, fullText] = buildSelectedFacetsAndFullText(
query,
Expand Down Expand Up @@ -403,7 +403,7 @@ const SearchQuery = ({
productSearchResult,
facetsLoading,
fetchMore,
} = useQueries(variables, facetsArgs, priceRange, sponsoredProductsBehavior)
} = useQueries(variables, facetsArgs, priceRange, sponsoredCount)

const redirectUrl = data && data.productSearch && data.productSearch.redirect

Expand Down

0 comments on commit 2b61ef8

Please sign in to comment.