Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Поиск дублей товаров в заказе в админке bitrix
if (typeof prods == 'undefined' || prods === null) {
let prods = {};
} else {
prods = {};
}
document.querySelectorAll('#sale_order_basketsale_order_view_product_table tbody[id*="sale_order_basketsale-order-basket-product-"] > tr:first-of-type').forEach(tr => {
let link = tr.querySelector('td:nth-of-type(2) > a');
if (!!link.href) {
let uri = new URL(link.href),
id = uri.searchParams.get('ID');
if (!!id) {
if (!prods[id]) {
prods[id] = {
'name': link.textContent,
'count': 0
}
}
prods[id].count += 1;
}
}
});
for (let prod in prods) {
if (prods.hasOwnProperty(prod)) {
if (prods[prod].count !== 1) {
console.log(prods[prod].name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment