Created
September 30, 2014 09:01
-
-
Save illarionvk/be3e1364da1721d9d8ce to your computer and use it in GitHub Desktop.
Automate adding numeric range to dropdown - Bold Apps Product Options app for Shopify
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
// Run the code in developer console, done best through Chrome's Javascript snippets | |
// First add LoDash | |
$('body').append('<script src="//cdn.jsdelivr.net/lodash/2.4.1/lodash.min.js"></script>'); | |
// Add range of steps to Bold Apps Product Option dropdown | |
(function() { | |
var valueRange = _.range(-5, 5.25, 0.25); | |
function addNewValue(value) { | |
$('#option_name').val(value); | |
$(".add_new_option .btn[data-original-title='Add Option']").click(); | |
} | |
_.forEach(valueRange, function(num, index) { | |
var escapedNum = (function() { | |
var numString = num + "" | |
if (num > 0) { | |
return '+' + numString | |
} else { | |
return numString.replace('-', '−') | |
} | |
})(); | |
window.setTimeout( | |
addNewValue, | |
index * 200 + 500, | |
escapedNum | |
); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment