Select which Bundles will match in real-time(dynamic priority)

In our Unlimited Bundles & Discounts Shopify App the Bundle(s) that the customer's cart will match are chosen in order via the priority attribute, some merchants might want to prioritize certain Bundles but in real-time, not via the priority attribute that is set in the Bundle creation.

It's possible to set in real-time which Bundles will have priority by updating/creating a cart attribute, below there is a guide on how to update the cart attribute via Shopify Ajax API:


https://shopify.dev/docs/api/ajax/reference/cart#update-cart-attributes


In order to prioritize one or multiple Bundles in the cart, you need to create the attribute, which the key will be "_revy_bundle_priorities", and the value will be the Bundle ID that is found here:

Open Bundle App > Edit a Bundle > Click in the section
Open Bundle App > Edit a Bundle > Click in the section "Embed Bundle in any Page"

With the Bundle ID in hands, you can make the request to update the Shopify cart attribute:

jQuery.post(window.Shopify.routes.root + 'cart/update.js', "attributes[_revy_bundle_priorities]=74871f5f-7355-4a44-89c9-46ab7da557b2");

The parameters will look like this:

{

attributes: {

'_revy_bundle_priorities': '74871f5f-7355-4a44-89c9-46ab7da557b2'

}

}

Multiple Bundles as Dynamic Priorities

In the example above just 1 Bundle was set as priority, if you want to prioritize multiple Bundles dynamically, just add the ID to the value using a comma to separate each ID, here's how will look like:


jQuery.post(window.Shopify.routes.root + 'cart/update.js', "attributes[_revy_bundle_priorities]=74871f5f-7355-4a44-89c9-46ab7da557b2,b9d42750-865c-4101-9e4f-b1f8aebceff9");

The parameters will look like this:

{

attributes: {

'_revy_bundle_priorities': '74871f5f-7355-4a44-89c9-46ab7da557b2,b9d42750-865c-4101-9e4f-b1f8aebceff9'

}

}

Remember that the ID's order matters, the 1st ID will have priority over the 2nd ID, the 2nd will have priority over the 3rd...etc.


Final Considerations


For most cases the priority attribute that is editable via the Revy Bundles Dashboard works just fine, this feature is useful for cases when the merchant wants to make sure that if the X Bundle is added to the cart it will match the X Bundle, instead of the Y Bundle that has the same products but has a better priority number.

With this feature you make sure that by adding the X Bundle, the customer will match the X Bundle, overwriting the matching order defined in the Revy Bundles Dashboard.

Still need help? Contact Us Contact Us