Created
January 24, 2018 17:19
-
-
Save therealkevinard/f794b228498a812a7bbbf6eb5bd6705c to your computer and use it in GitHub Desktop.
Woocommerce: when you have 221 variants that were mistakenly disabled.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-------------------------- | |
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