【问题标题】:Refresh variation product description after variant changed in Woocommerce在 Woocommerce 中更改变体后刷新变体产品描述
【发布时间】:2022-09-26 02:47:26
【问题描述】:

所以我将变体描述移动到单个产品页面的附加信息选项卡中,一切都像魅力一样工作,但每个变体的描述只有当我点击页面上的任何内容时才会显示。当然,我希望在选择变体后立即刷新。我有 WooCommerce 插件的 Variation Swatches,这会导致整个问题。

那是我使用的一段代码(由 LoicTheAztec 创建)

add_action( \'wp_footer\', \'move_variation_description\' );
function move_variation_description(){
    global $product;
    // Only on single product pages for variable products
    if ( ! ( is_product() && $product->is_type(\'variable\') ) ) return;
    // jQuery code
    ?>
    <script type=\"text/javascript\">
        jQuery(function($){
            a = \'.woocommerce-variation-description\', b = a+\' p\', c = \'input.variation_id\',
            d = \'#tab-additional_information\', de = $(d).html();

            // On load, adding a mandatory very small delay
            setTimeout(function(){
                // variation ID selected by default
                if( \'\' != $(c).val() && $(a).text() != \'\' )
                    $(d).html($(a).html());
            }, 300);

            // On live event (attribute select fields change)
            $(\'table.variations ul li\').on( \'blur\', function(){
                // variation ID is selected
                
               
                if( \'\' != $(c).val() && $(a).text() != \'\' ){
                    $(d).html($(a).html()); 

                }
                // No variation ID selected
                else {
                    $(d).html($(a).html()); // We set back the variable product description
                }
        
            });
        });

 

    </script>

我试图制作一些脚本来触发点击(正如我所说,当我点击页面上的任何内容时,描述刷新)但它也不起作用,有人可以帮忙吗?

    标签: wordpress woocommerce


    【解决方案1】:

    我也需要对上述问题有一个答案。有人可以帮忙吗?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 2018-08-31
    • 2021-04-24
    • 2021-06-22
    • 1970-01-01
    • 2019-04-17
    相关资源
    最近更新 更多