Skip to content

Commit

Permalink
Preselect swatch if only 1 swatch exists (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred authored and peterjaap committed Apr 1, 2019
1 parent 7d364ed commit 1f30544
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Elgentos_LargeConfigProducts" setup_version="0.1.10">
<module name="Elgentos_LargeConfigProducts" setup_version="0.1.11">
<sequence>
<module name="Magento_ConfigurableProduct" />
<module name="Magento_Framework" />
Expand Down
6 changes: 6 additions & 0 deletions view/frontend/web/js/swatch-renderer-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ define([
});

$(updatedSelectBoxes).change();

// Preselect swatch if only 1 swatch exists
const selectSwatch = document.querySelectorAll('.swatch-option');
if($(selectSwatch).length == 1) {
$(selectSwatch).trigger("click");
}
});
},

Expand Down

0 comments on commit 1f30544

Please sign in to comment.