2017-01-06 3 views
1

woocommerce 제품 템플릿을 수정하여 주요 제품 설명 바로 뒤에 있지만 관련 제품 앞에 일부 코드 (배너)를 추가하고 싶습니다.Wordpress/Woocommerce - 제품 컨텐트 이후에 관련 제품 이전에 템플릿 편집

코드 편집 중 (/wp-content/plugins/woocommerce/templates/single-product.php);

<?php 
    /** 
    * woocommerce_before_main_content hook. 
    * 
    * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) 
    * @hooked woocommerce_breadcrumb - 20 
    */ 
    do_action('woocommerce_before_main_content'); 
?> 

    <?php while (have_posts()) : the_post(); ?> 

     <?php wc_get_template_part('content', 'single-product'); 

          /*My code start*/ 
     echo "<div class=\"product-footer\">"; 
     echo "<h1 class=\"product-footer-text\">Need some additional help? Or have an enquiry?</h1>"; 
     echo "<h5 class=\"product-footer-text\"><i class=\"fa fa-phone\"></i>  Call one of our sales team on <strong>01782</strong></h5>"; 
     echo "<h5 class=\"product-footer-text\" style=\"margin-top: -40px;\"><i class=\"fa fa-envelope\"></i>  Contact us via our contact page <strong><a style=\"color: #ffffff;\" href=\"/../contact\" target=\"_blank\">HERE</a></strong></h5>"; 
     echo "<p class=\"product-footer-text\"><i><strong>Order note: </strong>All prices above are subject to delivery charges and VAT where applicable </i></span></p> 
    </div>"; 
          /*My code end*/ 

    ?><?php endwhile; // end of the loop. ?> 

<?php 
    /** 
    * woocommerce_after_main_content hook. 
    * 
    * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content) 
    */ 
    do_action('woocommerce_after_main_content'); 
?> 

<?php 
    /** 
    * woocommerce_sidebar hook. 
    * 
    * @hooked woocommerce_get_sidebar - 10 
    */ 
    do_action('woocommerce_sidebar'); 
?> 
나에게 결과를 제공되며, https://i.stack.imgur.com/sTgY6.png

하단의 배너를 제품 desc 아래에 표시하고 싶습니다. 필자는 꽤 잠시 동안 코드를 엉망으로 만들었고 그냥 작동하지 않는 것 같습니다.

답변

1

대신 템플릿을 무시하려고, 당신은 하나의 제품 탭 (제품 설명) 및 관련 제품 간의 사용자 정의 컨텐츠를 얻을 수 1015 사이의 우선 순위 woocommerce_after_single_product_summary 후크를 사용할 수 있습니다.

그래서 코드가 활성 자식 테마 (또는 테마)의 function.php 파일 대신에 위치합니다
/** 
* woocommerce_after_single_product_summary hook. 
* 
* @hooked woocommerce_output_product_data_tabs - 10 
* @hooked woocommerce_upsell_display - 15 
* @hooked woocommerce_output_related_products - 20 
*/ 

이 :이 후크의 스키마 아래 참조

add_action('woocommerce_after_single_product_summary', 'custom_single_product_banner', 12); 
function custom_single_product_banner() { 

    $output = '<div class="product-footer"> 
     <h1 class="product-footer-text">Need some additional help? Or have an enquiry?</h1> 
     <h5 class="product-footer-text"><i class="fa fa-phone"></i> Call one of our sales team on <strong>01782</strong></h5> 
     <h5 class="product-footer-text" style="margin-top: -40px;"><i class="fa fa-envelope"></i> Contact us via our contact page <strong><a style="color: #ffffff;" href="/../contact" target="_blank">HERE</a></strong></h5> 
     <p class="product-footer-text"><i><strong>Order note: </strong>All prices above are subject to delivery charges and VAT where applicable </i></span></p> 
    </div>'; 
    echo $output; 
} 

이 코드를 테스트하고, 공장.

+0

대단히 감사합니다! –

관련 문제