2017-06-15 8 views
1

私は、バリエーションの説明の場所をWooCommerceサイトのカートに追加ボタンの下に移動しようとしています。私はそれはJSのテンプレートを使用している(バリエーション製品のすべての他の部分とは違って)いることに気づく:WooCommerce移動のバリエーションの説明

<script type="text/template" id="tmpl-variation-template"> 
    <div class="woocommerce-variation-description"> 
     {{{ data.variation.variation_description }}} 
    </div> 

    <div class="woocommerce-variation-price"> 
     {{{ data.variation.price_html }}} 
    </div> 

    <div class="woocommerce-variation-availability"> 
     {{{ data.variation.availability_html }}} 
    </div> 
</script> 
<script type="text/template" id="tmpl-unavailable-variation-template"> 
    <p><?php _e('Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce'); ?></p> 
</script> 

しかし、私はテンプレートに周りにそのコードを移動しようとすると、それだけで正確に同じ場所にとどまります私はそれをカートに追加ボタンの後に置いたとしても。

また、herehereのフックコードも試しましたが、これも失敗します(私が使用しているWooCommerce 3以上で何かが変更されたと思われます)。誰でもバリエーション記述の移動方法を知っていますか?

答えて

0
おそらく

ない周りの最善の解決策が、あなたはあなたのfunction.phpでのjQueryのビットを使用することができ、それを達成するために:「製品-短い」あなたの説明のコンテナによってを置き換え

/*Move the description div to another one 
    ===================================== */ 
    add_action('wp_footer', 'move_composite_product_tab'); 
    function move_composite_product_tab() { 
     if (is_product()) : 
     ?> 
     <script> 
      jQuery(document).ready(function($) { 
       $(window).load(function() { 
        $(".product-short").wrap("<div id='variation-excerpt'></div>"); 
        $(".variations_form").after("<div class='product-after-main'></div>"); 
        document.getElementsByClassName("product-after-main")[0].appendChild(
        document.getElementById("variation-excerpt") 
        ); 
       }); 
      }); 
     </script> 
    <?php 
    endif; 
    } 

  1. 商品の説明の前後に折り返します。
  2. 目的のdivの後に新しいクラスを作成する
  3. ラップされたdiv(#バリエーション - 抜粋)を新しい作成済みのもの(.product-after-main)の下に移動します。

希望すると助かります!乾杯。

+0

ありがとう、感謝します。私は代わりに使うことができるフックがあることを望んでいますが、他の人が応答しない場合、または他の人が見つからない場合は、これを実行します。 – Stephen

+0

おそらくそれのためのフックがありますが、3.x以来、残念ながら、WooCommerceに関していくつかの良い答えをオンラインで見つけるのはかなり難しくなりました。時間は物事を行うだろう;) – bkseen

関連する問題