Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aatronco/54f6e6de9e210f400898c979aa79f9e2 to your computer and use it in GitHub Desktop.
Save aatronco/54f6e6de9e210f400898c979aa79f9e2 to your computer and use it in GitHub Desktop.
<script>
$('form#product-form select').each(function(i, select){ // product-form is the ID of my form, may change on your theme, verify in the design template of the products
var $select = $(select);
$select.find('option').each(function(j, option){
var $option = $(option);
// Create a radio:
var $radio = $('<input type="radio" />');
// Set name and value:
$radio.attr('name', $select.attr('name')).attr('value', $option.val());
// Set checked if the option was selected
if ($option.attr('selected')) $radio.attr('checked', 'checked');
// Insert radio before select box:
$select.before($radio);
// Insert a label:
$select.before(
$("<img src='https://assets.jumpseller.com/store/alejandrotest/themes/143922/"+$option.text()+".png'><label />").attr('for', $select.attr('name')).text($option.text())
); // This is the asset address on my test store, you should use yours. The name alejandro test and the number 143922 should change. Its using the name of the options, you shuld have your iamges with the same name
// Insert a <br />:
$select.before("<br/>");
});
$select.remove();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment