document.addEventListener('DOMContentLoaded', () => { const priceEl = document.getElementById('product-price'); function getSelected(name) { return document.querySelector( `input[type="radio"][name="${name}"]:checked` ); } function readNumber(el, attr) { if (!el) return 0; const raw = el.getAttribute(attr); const n = raw !== null ? Number(raw) : 0; return Number.isFinite(n) ? n : 0; } // for multipliers like subMult, cFormMult, finMult // default to 1 (no change) instead of 0 function readMultiplier(el, attr) { if (!el) return 1; const raw = el.getAttribute(attr); if (raw === null) return 1; const n = Number(raw); if (!Number.isFinite(n) || n === 0) return 1; return n; } // substrate key from the substrate radio // expects data-sub="canvas" | "metal" | "fineartpaper" | "lusterpaper" function getSubstrateKey(subEl) { if (!subEl) return null; const keyAttr = subEl.getAttribute('data-sub'); if (keyAttr) return keyAttr.trim().toLowerCase(); const val = (subEl.value || '').trim().toLowerCase(); return val || null; } // read pp/sq inch from the size radio based on substrate // expects e.g. data-pp-sqi-canvas, data-pp-sqi-metal, etc. function getPpSqiForSizeAndSubstrate(sizeEl, subEl) { if (!sizeEl || !subEl) return 0; const key = getSubstrateKey(subEl); if (!key) return 0; const attrName = `data-pp-sqi-${key}`; return readNumber(sizeEl, attrName); } function setPriceValue(input, amount) { if (!input) return; const val = input.value || ''; const prefixMatch = val.match(/^([^{}]*)/); let prefix = prefixMatch ? prefixMatch[1] : ''; if (!prefix) prefix = input.name || ''; input.value = `${prefix}{p+${amount}}`; } function recalc() { const sizeEl = getSelected('size'); const subEl = getSelected('substrate'); const canvasEl = getSelected('canvas-format'); const finishEl = getSelected('finish'); const frameEl = getSelected('frame'); // size-related const area = readNumber(sizeEl, 'data-area'); const perimeter = readNumber(sizeEl, 'data-perimeter'); // substrate / canvas / finish multipliers const subMult = readMultiplier(subEl, 'data-sub-mult'); const cFormMult = readMultiplier(canvasEl, 'data-c-form-mult'); const finMult = readMultiplier(finishEl, 'data-fin-mult'); // frame-related const ppFoot = readNumber(frameEl, 'data-pp-foot'); // price per foot const fWidth = readNumber(frameEl, 'data-f-width'); // inches // substrate-specific pp/sq inch from size radio const ppSqi = getPpSqiForSizeAndSubstrate(sizeEl, subEl); console.log({ area, ppSqi, subMult, cFormMult, finMult, ppFoot, fWidth }); //------------------------------------------------------------------------ // FORMULA //------------------------------------------------------------------------ const sizePrice = area * ppSqi; const substratePrice = sizePrice * (subMult - 1); const canvasFormatPrice = sizePrice * (cFormMult - 1); const finishPrice = sizePrice * (finMult - 1); const framePrice = (perimeter + 8 * fWidth) / 12 * ppFoot; //------------------------------------------------------------------------ // FORMULA //------------------------------------------------------------------------ const totalPrice = sizePrice + substratePrice + canvasFormatPrice + finishPrice + framePrice; // Foxy values setPriceValue(sizeEl, sizePrice); setPriceValue(subEl, substratePrice); setPriceValue(canvasEl, canvasFormatPrice); setPriceValue(finishEl, finishPrice); setPriceValue(frameEl, framePrice); // formatted display, e.g. $1402.85 if (priceEl) { const safeTotal = Number.isFinite(totalPrice) ? totalPrice : 0; priceEl.textContent = `$${safeTotal.toFixed(2)}`; } } const radios = document.querySelectorAll( 'input[type="radio"][name="size"],' + 'input[type="radio"][name="substrate"],' + 'input[type="radio"][name="canvas-format"],' + 'input[type="radio"][name="finish"],' + 'input[type="radio"][name="frame"]' ); radios.forEach(radio => radio.addEventListener('change', recalc)); recalc(); });
Bryce Canyon Winter Sunrise
by  
artist
--loose-canvas
--s-box
Size
12x18
Substrate
canvas
finish
semi-gloss
Frame
p2654
Size
Substrate
Paper
Canvas
Metal
Canvas Format
Stretched Canvas
Not to be hung on a wall directly without a standard or shadowbox frame
Gallery Wrap
May be hung on a wall directly, or framed in a floater frame
Loose Canvas
Non-stretched canvas shipped as in a roll – Not wall-art ready
Paper Type
Fine Art Paper
Luster Paper
Canvas Finish
Gloss
Semi-Gloss
Matte
Metal Finish
Gloss
Semi-Gloss
Matte
Frames
P2607
0.875
"
P2608
0.875
"
P2650
0.875
"
P2654
0.875
"
P2655
0.875
"
P2656
0.875
"
P2657
0.875
"
P2658
0.875
"
H4257
1.25
"
N4517
1.375
"
N4519
1.375
"
N4520
1.375
"
N4522
1.375
"
N4523
1.375
"
H4267
1.5
"
417-2108
2.125
"
H1117
2.125
"
H4287
3
"
418-2108
3.125
"
EC435
3.25
"
EC888
3.25
"
EC889
3.25
"
EC1605
0.375
"
EC1607
0.375
"
EC1608
0.375
"
EC1610
0.375
"
EC1907
0.5625
"
EC1908
0.5625
"
EC1910
0.5625
"
EC1918
0.5625
"
EC1919
0.5625
"
EC1922
0.5625
"
P4011
0.9375
"
P4012
0.9375
"
P4013
0.9375
"
P4014
0.9375
"
P4015
0.9375
"
EC1407
1.125
"
P2007
1.375
"
P2008
1.375
"
P2020
1.4375
"
V1267
0.8125
"
V1268
0.8125
"
V1367
0.8125
"
V1368
0.8125
"
EC906
1
"
EC907
1
"
EC908
1
"
P3455
1
"
P3457
1
"
P3458
1
"
P3459
1
"
P3463
1
"
P3464
1
"
N570
1.5
"
$test-compare
$0.00
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Bryce Canyon Winter Sunrise
Size:
substrate:
finish:
frame:
Bryce Canyon Winter Sunrise
Size:
substrate:
finish:
frame: