修改
app\design\frontend\**\template\catalog\product\view\type\options\configurable.phtml
内容
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $_jsonConfig ?>);
</script>
<?php echo $this->getChildHtml('after') ?>
<?php endif;?>
为
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
function fireEvent(element,event){
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
}
Event.observe(window, 'load', function() {
spConfig.settings[0].selectedIndex = 1;
obj = spConfig.settings[0]; // this grabs the first select item
Event.observe(obj,'change',function(){});
fireEvent(obj,'change'); // this simulates selecting the first option, which triggers
spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu
});
</script>
<?php echo $this->getChildHtml('after') ?>
<?php endif;?>
以porto主题为例.修改完以上代码后则可实现添加到购物车不会有提示,但是在页面外观并没有展现,需要修改
修改完成之后如图示