Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save therealkevinard/f794b228498a812a7bbbf6eb5bd6705c to your computer and use it in GitHub Desktop.
Save therealkevinard/f794b228498a812a7bbbf6eb5bd6705c to your computer and use it in GitHub Desktop.
Woocommerce: when you have 221 variants that were mistakenly disabled.
/*--------------------------
Usage: Plunk this in the browser's js console.
- run checkUnchecked() to check all the unchecked things.
- run reportUnchecked() to see if anything isn't checked (useful to circle-back after going through 15 pages: wrap it in setInterval and flip back through
*/
window.collectCheckboxes = function () {
return Array.from(
jQuery('[name*="variable_enabled"]')
);
}
window.removeEnabled = function (el) {
return !el.checked;
}
/**
* Finds unchecked things, then checks them
*/
window.checkUnchecked = function () {
var notChecked = collectCheckboxes()
.filter(removeEnabled)
var checked = notChecked
.map(function (el) {
$(el).click();
})
console.log(checked)
}
/**
* Looks for unchecked things.
*/
window.reportUnchecked = function () {
var notChecked = collectCheckboxes()
.filter(removeEnabled);
console.log(notChecked.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment