To dynamically update the price based on checkbox selections and pass that price to the cart in Webflow, you’ll need custom code since Webflow’s native eCommerce system doesn’t support conditional product pricing out of the box.
Here’s how to structure a solution using jQuery and Webflow’s Custom Code Embed functionality.
---
$49.00) using a class like .product-price.data-price="10" to hold the additional cost..addon-checkbox.
data-price="10")data-price="5")
---
<script>
$(document).ready(function () {
const basePrice = 49; // replace with your base price
const $priceDisplay = $('.product-price');
function updatePrice() {
let total = basePrice;
$('.addon-checkbox:checked').each(function () {
total += parseFloat($(this).data('price'));
});
$priceDisplay.text(`$${total.toFixed(2)}`);
}
$('.addon-checkbox').on('change', updatePrice);
updatePrice(); // initial update
});
</script>
.product-price and .addon-checkbox with the actual classes used in your Webflow project.
---
Webflow's eCommerce system only allows adding predefined products, so to send a dynamic price, you must:
Webflow.push() API to send custom data.
Example (add this inside the same <script> block):
$('.add-to-cart-button').on('click', function (e) {
e.preventDefault();
let total = basePrice;
let options = [];
$('.addon-checkbox:checked').each(function () {
let price = parseFloat($(this).data('price'));
let label = $(this).next('label').text();
total += price;
options.push(label);
});
window.Webflow.require('cart').add({
productId: 'YOUR-WEBFLOW-PRODUCT-ID',
quantity: 1,
customData: [
{ name: "Selected Options", value: options.join(', ') },
{ name: "Adjusted Price", value: `$${total.toFixed(2)}` }
],
price: total * 100 // in cents
});
});
'YOUR-WEBFLOW-PRODUCT-ID' with the actual product ID.
---
---
To dynamically update product price with checkboxes and reflect that in the cart:
cart.add() API with custom price and options.
For fully dynamic pricing and product options, also consider using tools like Finsweet Attributes or integrating a third-party cart like Foxy.io if complexity increases.