О каких классах и data-атрибуте идёт речь:
const class1 = 'item';
const class2 = 'in';
const key = 'price';
const attr = `data-${key}`;
Как извлечь значение атрибута:
const getValue = el => +el.dataset[key];
// или
const getValue = el => parseFloat(el.getAttribute(attr));
// или
const getValue = el => Number(el.attributes[attr].value);
Извлекаем, складываем:
const sum = Array.prototype.reduce.call(
document.querySelectorAll(`.${class1}.${class2}`),
(acc, n) => acc + getValue(n),
0
);
// или
let sum = 0;
for (const n of document.getElementsByClassName(class1)) {
sum += getValue(n) * n.classList.contains(class2);
}