隐藏可配置产品的“添加到愿望列表”按钮,直到选择一个选项


Hide Add to Wishlist button for configurable products until an option is selected

我在一个magento网站上遇到了一个问题,如果用户将可配置的产品添加到愿望列表中,就会引发致命错误。我想做的是添加一些javascript,隐藏"添加到愿望列表"按钮,直到用户选择了一个可配置的选项——但我不知道怎么做!感谢您的帮助。

这很有效。。。

在template/cacatalog/product/view/addto.phtml中,我添加了以下内容:

<?php
if($_product->getTypeID() === 'configurable') {
    // Hide the button until a selection has been made
?>
<script type="text/javascript">
    jQuery(".add-to-links").hide();
    jQuery(".super-attribute-select").on("change", function() {
        var val = jQuery(".super-attribute-select").val();
        if(val == '') {
            jQuery(".add-to-links").hide();
        }
        else {
            jQuery(".add-to-links").show();
        }
    });
</script>
<?php } ?>

要隐藏"添加到心愿单",请转到管理部分,然后选择系统->配置,查看左侧的客户选项卡,单击心愿单,在常规选项->启用上选择否,然后单击保存配置。这将禁用"添加到愿望单"链接。