Skip to content

Instantly share code, notes, and snippets.

@glebsneg
glebsneg / acf-price.js
Created May 6, 2025 13:25
Demo WooCommerce with ACF
document.addEventListener('DOMContentLoaded', function () {
const priceElement = document.querySelector('.woocommerce-Price-amount bdi');
const extraPriceElement = document.querySelector('.acf-extra-price');
if (priceElement && extraPriceElement) {
const basePrice = parseFloat(priceElement.textContent.replace(/[^\d.]/g, ''));
const extra = parseFloat(extraPriceElement.dataset.extra);
if (!isNaN(basePrice) && !isNaN(extra)) {
const newPrice = basePrice + extra;