Menu
Guides
VTEX IO Apps

VTEX IO Apps
Buybox Context
Community extension
Version: 1.1.1
Latest version: 1.1.1

Source code

{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABCAIAAAB2XpiaAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAFUlEQVR4nGNgZ2c3MzYSV1L/f2UuAAziA4F6BhfzAAAAAElFTkSuQmCC","img":{"src":"https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square","width":110,"height":20,"type":"svg"}}

This app is no longer maintained by VTEX. This means support and maintenance are no longer provided.

The Buybox Context is a component that enables sorting sellers for products sold by multiple sellers. When Buybox context wraps a Product context, it reorders sellers and sets the new sellerDefault on the current product's seller list.

Configuration

In this section, you first must add the primary instructions that will allow users to use the app's blocks in their store, such as:

  1. Adding the app as a theme dependency in the manifest.json file;

_10
"dependencies": {
_10
"vtexbr.buybox-context": "1.x"
_10
}

If you want to use the vtex.seller-selector app to boost your development, you can add it as a dependency in the manifest.json file


_10
"dependencies": {
_10
"vtex.seller-selector": "0.x"
_10
}

  1. Wrap a block that uses the Product Context and configure the sortStrategy that will be used to sort the sellers.

_11
"buybox-context": {
_11
"props": {
_11
"conditionalStrategy": {
_11
"sortStrategy": "priceShipping",
_11
}
_11
"triggerCepChangeEvent": "sellerSelector"
_11
},
_11
"children": [
_11
...
_11
]
_11
}

Now, you are able to use all the blocks exported by the buybox-context app. Check out the full list below:

buybox-context props

Prop nameTypeDescriptionDefault value
conditionalStrategyobjectObject responsible for providing the sort strategy and custom expressions.undefined
triggerCepChangeEventenumThe Buybox Context depends on the CEP event to get the Sellers of the Product. Depending on context, the Buybox Context is used. You can select what this component will be listening to intercept changes and reorder sellers."orderForm"
childrenarrayArray with block components, that use the Product Context to sort sellers.null
  • conditionalStrategy props
Prop nameTypeDescriptionDefault value
sortStrategyenumUse to select which sort strategy will be used to sort the sellers. If this prop isn't informed, nothing will be done.undefined
expressionstringCustom expression based on a math expression, with predefined variables. The lowest value resulting from this expression will be positioned at the top of the seller's list. For more details about how to create expressions, click here.undefined
  • sortStrategy enum:

    Prop nameTypeDescription
    pricestringSort sellers only product price. The sellers at the top of the list will have the lowest prices.
    priceShippingstringSort sellers by product price + shipping price. The lower of these two values will be placed at the top of the seller's list.
    customExpressionstringSort sellers by a custom expression based on a math expression, with predefined variables. The lowest value resulting from this expression will be positioned at the top of the seller's list. For more details about how to create expressions, click here
    protocolstringSort sellers using a protocol defined on buybox-graphql. This protocol defines the contract for receiving and responding with the sorted data. For that to work, a resolver for this contract must be implemented. The buybox-resolver was created as an example of that implementation.
  • triggerCepChangeEvent enum:

    Prop nameTypeDescription
    orderFormstringUsed for listening useOrderForm() changes, to get sellers and logistics info to sort seller list with new shipping values.
    sellerSelectorstringUsed for listening useSellerContext() changes, to get sellers and logistics info to sort seller list with new shipping values.
  • children array: Array with block components

The sortStrategy and triggerCepChangeEvent can be changed using Site Editor.

Custom expression variables

VariableEntityDescription
productPriceProductProduct price
productSpotPriceProductProduct spot price
productAvailableQuantityProductProduct available quantity
minShippingPriceShippingCheapest shipping price
maxShippingPriceShippingMost expensive shipping price
minShippingEstimateShippingMinimum estimated delivery time
maxShippingEstimateShippingMaximum estimated delivery time

seller-body.buybox props

Prop nameTypeDescriptionDefault value
childrenarrayArray with block components. See seller-sellector for more information.null
  • children array: Array with block components.

Dependences

Modus Operandi

Product Page

On the product page, you can add the buybox-context where it makes sense to select the Buybox winner. In the example below, flex-layout.col#right-col is the block that contains product values and conditions. See below:


_10
{
_10
...
_10
"flex-layout.row#product-main": {
_10
"children": [
_10
"flex-layout.col#stack",
_10
"flex-layout.col#right-col"
_10
]
_10
}
_10
...
_10
}

After adding the buybox-context in this example, the new code will be like below:


_22
{
_22
...
_22
"flex-layout.row#product-main": {
_22
"children": [
_22
"flex-layout.col#stack",
_22
- "flex-layout.col#right-col"
_22
+ "vtex.buybox-context:buybox-context#product-col"
_22
]
_22
},
_22
+ "vtex.buybox-context:buybox-context#product-col": {
_22
+ "props": {
_22
+ "conditionalStrategy": {
_22
+ "sortStrategy": "priceShipping"
_22
+ },
_22
+ "triggerCepChangeEvent": "orderForm"
_22
+ },
_22
+ "children": [
_22
+ "flex-layout.col#right-col"
_22
+ ]
_22
+ },
_22
...
_22
}

By default, the prop triggerCepChangeEvent value is orderForm, which makes this prop optional.

Sellers

With seller-selector and buybox-context installed in your theme, you can create or edit a file in store/blocks/sellers/sellers.jsonc and add the code below:


_24
{
_24
"store.sellers": {
_24
"blocks": ["vtex.seller-selector:seller-table"]
_24
},
_24
"vtex.seller-selector:seller-table": {
_24
"children": [
_24
"vtex.seller-selector:seller-simulate-shipping",
_24
"vtex.seller-selector:seller-head",
_24
"buybox-context"
_24
]
_24
},
_24
"buybox-context": {
_24
"props": {
_24
"conditionalStrategy": {
_24
"sortStrategy": "priceShipping"
_24
},
_24
"triggerCepChangeEvent": "sellerSelector"
_24
},
_24
"children": ["seller-body.buybox"]
_24
},
_24
"seller-body.buybox": {
_24
"children": ["vtex.seller-selector:seller-row"]
_24
}
_24
}

That way, you will have a page similar to this:

{"base64":"  ","img":{"width":1907,"height":1001,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":113471,"url":"https://user-images.githubusercontent.com/17439470/133501110-e143b472-1b58-4ee8-8759-8096ca32df0c.png"}}

To have the full behaviour using seller-body.buybox, it will be necessary to set the triggerCepChangeEvent as sellerSelector props on buybox-context. Because the default value for this parameter is orderForm, but on this page we usually use the seller-simulate-shipping to calculate shipping

Customization

In order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on Using CSS Handles for store customization.

CSS Handles
sellerList
On this page
Configuration
Was this helpful?