In the _ProductAttributes.cshtml (go for the one under your Theme directory if you have this file there)
Add after the first '@foreach {' (~ line 15)
string preselect = @Context.Request.Query[attribute.Name].ToString();
at line 33 begins a long switch statement beginning with the line '@switch (attribute.AttributeControlType)' it goes thru all possible types of attributes, my implementation is for the following attribute types:
RadioList, ColorSquares, ImageSquaresfor these three add after their '@foreach (var attributeValue in attribute.Values) {'
if (!string.IsNullOrEmpty(preselect)) {
attributeValue.IsPreSelected = (preselect == attributeValue.Name);
}
Checkboxes, ReadonlyCheckboxesafter the '@foreach (var attributeValue in attribute.Values) {' add:
if (!string.IsNullOrEmpty(preselect)) {
attributeValue.IsPreSelected = (preselect.Split(',').Any(x => x == attributeValue.Name));
}
Textbox, MultilineTextbox add to both right after the 'case' lines:
if (!string.IsNullOrEmpty(preselect)) attribute.DefaultValue = preselect;
USAGE:http(s)://yourstoreurl.com/productname?attributename1=value&attributename2=value...
examples:
http(s)://yourstoreurl.com/cake?message=Happy%20Birthday
http(s)://yourstoreurl.com/tshirt?size=Large&color=Blue
in case of multiple selections ie. checkboxes, the value can be a comma separated list:
http(s)://yourstoreurl.com/productname?extras=abs,ac,heatedseats (all three will be prechecked)
This feature overrides the Default values for preselection you have any stored with your product data. The attribute names are those you registered the attribute with, these are NOT case-sensitive, but the attribute values are case sensitive.
Caveat. No error/security considerations were made, the query part of the url gets ignored without my code, there might be some content validation, like length limiting, or injected code check needed.