Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sponsoredCount prop #691

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion react/utils/getCookie.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { canUseDOM } from 'exenv'
import { canUseDOM } from 'vtex.render-runtime'

function getCookie(cname) {
if (!canUseDOM) {
Expand Down
Loading