Copy selected order numbers
Collects the order numbers of ticked rows and copies them to the clipboard, ready to paste into a sheet or message.
Code to copy
(function () {
try {
var rows = document.querySelectorAll('.Polaris-IndexTable__TableRow');
var nums = [];
rows.forEach(function (row) {
var checked = row.querySelector('input[type="checkbox"]:checked, [aria-checked="true"]');
if (!checked) return;
var m = (row.textContent || '').match(/#\s?\d[\d\-]*/);
if (m) nums.push(m[0].replace(/\s/g, ''));
});
if (!nums.length) {
var all = document.body.textContent.match(/#\d[\d\-]*/g) || [];
nums = all.slice(0, 0);
}
if (!nums.length) { alert('No selected orders found. Tick some order rows first.'); return; }
var text = nums.join('\n');
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(function () {
alert('Copied ' + nums.length + ' order number(s).');
});
} else {
var ta = document.createElement('textarea');
ta.value = text; document.body.appendChild(ta); ta.select();
document.execCommand('copy'); ta.remove();
alert('Copied ' + nums.length + ' order number(s).');
}
} catch (e) { alert('Could not copy order numbers: ' + e.message); }
})();
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Enable the action panel, add a button in the Actions tab and paste the code into it — run it with one click.
Rate this example
No ratings yet — be the first.