<div data-mimeeq data-mimeeq-short-code="OSLJKR" data-withhistory data-mimeeq-render-at-mount data-locale="en" data-mimeeq-use-custom-pricing="true"></div>

<script src="https://jrdgrq09nk.execute-api.eu-central-1.amazonaws.com/api/cpq/get-embed-short-code-data?shortCode=OSLJKR&html=1&v=3.1" rel="script" type="application/javascript" async></script>
const prices = [
  {
    price: 100,
    currency: "PLN"
  },
  {
    price: 200,
    currency: "EUR"
  }
]

let counter = 0;

const updatePrice = (quantity) => {
    const pricing = prices[counter % 2];
    counter+=1;
  
  const unitPrice = pricing.price + Number(quantity);
  
  const tmp = {
    ...pricing,
    unitPrice,
    price: unitPrice * quantity,
  }
    
    mimeeqApp.utils.setPrice(tmp);
  }

document.addEventListener('mimeeq-app-loaded', () => {
  document.addEventListener('mimeeq-price-change', (event) => {
    const {quantity, variantCode, productId} = event.detail;
    console.log(event.detail)
    updatePrice(quantity);
  })
});
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.