-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(client/recommend): small refactor and cleanup to types
- Loading branch information
1 parent
f5f8084
commit f285488
Showing
7 changed files
with
138 additions
and
162 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,9 @@ It is recommended to utilize the [`RecommendationInstantiator`](https://github.c | |
profile: 'recently-viewed', | ||
target: '.above-content', | ||
options: { | ||
limit: 5, | ||
limit: 5 | ||
} | ||
}, | ||
} | ||
]; | ||
</script> | ||
``` | ||
|
@@ -31,7 +31,7 @@ Context variables may be applied to individual recommendation profiles similar t | |
| products | array of SKU strings | product detail page | SKU value(s) to identify the current product(s) being viewed | | ||
| cart | array (or function that returns an array) of current cart skus | all | optional method of setting cart contents | | ||
| shopper.id | logged in user unique identifier | all | required for personalization functionallity if not provided to the bundle (global) context | | ||
| profiles | array of profile objects | all | required profile specific variables | | ||
|
||
|
||
### Profile Specific Variables | ||
| Option | Value | Page | Description | | ||
|
@@ -42,12 +42,11 @@ Context variables may be applied to individual recommendation profiles similar t | |
| options.categories | array of category path strings | all | optional category identifiers used in category trending recommendation profiles | | ||
| options.brands | array of brand strings | all | optional brand identifiers used in brand trending recommendation profiles | | ||
| options.branch | template branch overwrite | all | optional branch overwrite for recommendations template (advanced usage) | | ||
| options.dedupe | boolean (default: `true`) | all | dedupe recs from other profiles in the batch | | ||
| options.dedupe | boolean (default: `true`) | all | dedupe products across all profiles in the batch | | ||
| options.searchTerm | string | all | query to search | | ||
| options.filters | array of filters | all | optional recommendation filters | | ||
| options.realtime | boolean | all | optional update recommendations if cart contents change (requires [cart attribute tracking](https://github.com/searchspring/snap/blob/main/docs/INTEGRATION_TRACKING.md)) | | ||
| options.blockedItems | array of strings | all | SKU values to identify which products to exclude from the response | | ||
| options.batched | boolean (default: `true`)| all | only applies to recommendation context, optional disable profile from being batched in a single request, can also be set globally [via config](https://github.com/searchspring/snap/tree/main/packages/snap-controller/src/Recommendation) | | ||
| options.order | number | all | optional order number for recommendation params to be added to the batched request. Profiles that do not specify an order will be placed at the end, in the occurrence they appear in the DOM. | ||
| options.limit | number (default: 20, max: 20) | all | optional maximum number of results to display, can also be set globally [via config globals](https://github.com/searchspring/snap/tree/main/packages/snap-controller/src/Recommendation) | | ||
|
||
|
@@ -59,48 +58,48 @@ In most cases batching everything is the best practice, however for profiles lik | |
The example below shows how to manually specify the order and batching of specific profiles. | ||
|
||
```html | ||
<script type="searchspring/recommendations" profile="customers-also-bought"> | ||
globals: { | ||
<script type="searchspring/recommendations"> | ||
globals = { | ||
products: ['product123']; | ||
} | ||
profiles: [ | ||
}; | ||
profiles = [ | ||
{ | ||
profile: 'customers-also-bought', | ||
target: '.crosssell', | ||
options: { | ||
limit: 5, | ||
limit: 5 | ||
} | ||
}, | ||
{ | ||
profile: 'customers-also-viewed', | ||
target: '.similar', | ||
target: '.similar' | ||
}, | ||
//same batch, but dedupe false | ||
{ | ||
profile: 'bundle', | ||
target: '.similar', | ||
options: { | ||
dedupe: false, | ||
dedupe: false | ||
} | ||
}, | ||
] | ||
} | ||
]; | ||
</script> | ||
|
||
<!-- seperate batch --> | ||
<script type="searchspring/recommendations" profile="quick-cart"> | ||
globals: { | ||
<script type="searchspring/recommendations"> | ||
globals = { | ||
products: ['product123'] | ||
} | ||
profiles: [ | ||
}; | ||
profiles = [ | ||
{ | ||
profile: 'quick-cart', | ||
target: '.crosssell', | ||
options: { | ||
limit: 5, | ||
limit: 5 | ||
} | ||
}, | ||
] | ||
} | ||
]; | ||
</script> | ||
``` | ||
|
||
|
@@ -112,49 +111,49 @@ A typical "similar" profile that would display products similar to the product p | |
|
||
```html | ||
<script type="searchspring/recommendations"> | ||
globals: { | ||
globals = { | ||
products: ['product123'] | ||
} | ||
profiles: [ | ||
}; | ||
profiles = [ | ||
{ | ||
profile: 'customers-also-viewed', | ||
target: '.similar' | ||
}, | ||
] | ||
} | ||
]; | ||
</script> | ||
``` | ||
|
||
If tracking scripts are not in place, "crosssell" profiles may require the cart contents to be provided. | ||
|
||
```html | ||
<script type="searchspring/recommendations"> | ||
globals: { | ||
globals = { | ||
cart: ['product123'] | ||
} | ||
profiles: [ | ||
}; | ||
profiles = [ | ||
{ | ||
profile: 'customers-also-bought', | ||
target: '.crosssell' | ||
}, | ||
] | ||
} | ||
]; | ||
</script> | ||
``` | ||
|
||
If the shopper identifier is not beeing captured by the `bundle.js` context, it must be provided for proper personalization. | ||
|
||
```html | ||
<script type="searchspring/recommendations"> | ||
globals: { | ||
globals = { | ||
shopper: { | ||
id: '[email protected]' | ||
}; | ||
} | ||
profiles: [ | ||
} | ||
}; | ||
profiles = [ | ||
{ | ||
profile: 'view-cart', | ||
target: '.cart' | ||
}, | ||
] | ||
} | ||
]; | ||
</script> | ||
``` | ||
|
||
|
@@ -163,7 +162,7 @@ The example shown below will filter the recommendations for products matching co | |
|
||
```html | ||
<script type="searchspring/recommendations"> | ||
profiles: [ | ||
profiles = [ | ||
{ | ||
profile: 'customers-also-bought', | ||
target: '.crosssell', | ||
|
@@ -186,7 +185,7 @@ The example shown below will filter the recommendations for products matching co | |
} | ||
] | ||
} | ||
}, | ||
] | ||
} | ||
]; | ||
</script> | ||
``` |
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
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
Oops, something went wrong.