【发布时间】:2023-03-04 00:41:02
【问题描述】:
我想编辑 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
我希望底部的横幅出现在产品说明下方。我一直在搞乱代码很长一段时间,但似乎无法让它工作。
【问题讨论】:
标签: php html wordpress web woocommerce