【问题标题】:Display a headline before order review table in WooCommerce checkout在 WooCommerce 结帐中的订单审核表之前显示标题
【发布时间】:2019-10-12 10:16:10
【问题描述】:

我正在尝试在 woocommerce 结帐订单审核表之前添加一个简单的标题。我不想用函数添加它,而是直接在 review-order.php 模板中添加(我覆盖了几件事,所以在我的子主题中覆盖模板是有意义的)。当我在模板中插入 -tag 时,它会显示两次而不是一次。我需要改变什么? review-order.php 模板的开头是:

<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<table class="shop_table woocommerce-checkout-review-order-table">

我试过了:

<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h3>My headline</h3>
<table class="shop_table woocommerce-checkout-review-order-table">

标题出现两次...

如何避免这个标题出现两次?

【问题讨论】:

    标签: php ajax wordpress templates woocommerce


    【解决方案1】:

    为避免此标题出现两次,请在 IF 语句中使用 ! is_ajax(),如下所示:

    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    
    if ( ! is_ajax() ) {
        echo '<h3>'.__("My headline", "woocommerce").'</h3>';
    }
    
    ?>
    <table class="shop_table woocommerce-checkout-review-order-table">
    

    这一次它将显示一次,因为您的标题不会刷新 ajax。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-28
      • 2021-05-07
      • 2021-11-16
      • 2019-12-11
      • 2014-10-08
      • 2020-10-20
      • 2021-05-07
      • 1970-01-01
      相关资源
      最近更新 更多