我们需要在review-order.php中有两个表来显示表1中的已开票项目和表2中的信用卡采购。
在这里,我对这个概念有一个基本的概述。
<?php if($gateways == 'bacs') { ?>
<div id="order_review">
<table class="shop_table">
<thead>
<tr>
<th class="product-name"><?php _e('Invoice Products', 'yit'); ?></th>
<th class="product-quantity"><?php _e('Qty', 'yit'); ?></th>
<th class="product-total"><?php _e('Totals', 'yit'); ?></th>
</tr>
</thead>
表2
<?php if($gateways == 'paypal') { ?>
<div id="order_review">
<table class="shop_table">
<thead>
<tr>
<th class="product-name"><?php _e('Credit Card Products', 'yit'); ?></th>
<th class="product-quantity"><?php _e('Qty', 'yit'); ?></th>
<th class="product-total"><?php _e('Totals', 'yit'); ?></th>
</tr>
</thead>
问题是,当将表封装在IF中时,这些表会完全消失
如果有人能提供一些更好的想法,我们将不胜感激。谢谢!
$gateway变量是从哪里获得的?在不知情的情况下,很难理解为什么您的代码不起作用。但这是获取网关的代码。
$available_gateways=$oocommerce->payment_gateways->get_available_payment_gateways();
foreach ( $available_gateways as $gateway ) {
if ( $gateway->chosen === 'paypal' ) {
// do something
}
// alternative you can try id if that matches
if ( $gateway->id === 'paypal' ) {
// do something
}
}