最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Hide 'add to cart' when certain value in dropdown is selected

programmeradmin3浏览0评论

Need help here please. I am trying to hide the 'add to cart' woocommerce button when a user selects a specific item in a dropdown list. I have tried multiple JQuery snippets in both functions.php and through 3rd party plugins but am still struggling to get it to work.

In Functions.php theme file

function load_scripts() {
?>
    <script type="text/javascript">
    $(document).ready(function(){
        $(document.getElementsByName("select-1574795073993")).change(function(){
            $( "select option:selected").each(function(){
                if($(this).attr("value")=="International"){
                    $(".single_add_to_cart_button").hide();
                }
            });
        }).change();
    });
    </script>
<?php
}
add_action('wp_enqueue_scripts', 'load_scripts');

Please can someone assist with simple steps to 1) provide correct code, and 2) insert in the woocommerce hosted plarform.

Much appreciated!

发布评论

评论列表(0)

  1. 暂无评论