remove "Choose an Option...“in config product detail page attribute option

1742 단어 attribute
<script>
spConfig.setInitialState = function(dropdown_id)
        {
            //select dropdown
            var dropdown = $(dropdown_id);
            //remove empty option from dropdown so it is not selectable after initial selection
            dropdown[0].remove();
            //change selections in dropdowns
            for(index = 0; index < dropdown.length; index++)
            {
                if(dropdown[index].value != "")
                {
                    dropdown.selectedIndex = index;
                    var element = dropdown;
                    var event = 'change';
                    //fire events
                    if(document.createEventObject)
                    {
                        var evt = document.createEventObject();
                        return element.fireEvent('on'+event,evt)
                    }
                    else
                    {
                        var evt = document.createEvent("HTMLEvents");
                        evt.initEvent(event, true, true );
                        return !element.dispatchEvent(evt);
                    }
                }
            }
        };
        <?php foreach($_attributes as $_attribute): ?>
        spConfig.setInitialState("attribute<?php echo $_attribute->getAttributeId() ?>")
        <?php endforeach; ?>
</script>

app/design/frontend/default/sanorita/template/catalog/product/view/type/options/configurable.phtml
파일 뒤에 이 JS를 추가합니다.

좋은 웹페이지 즐겨찾기