我只想为登录用户显示“货到付款”网关付款。显示可用付款的循环代码是这样的:
<ul class="payment_methods methods">
<?php
if ( $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways() ) {
// Chosen Method
if ( sizeof( $available_gateways ) )
current( $available_gateways )->set_current();
foreach ( $available_gateways as $gateway ) {
?>
<li>
<input type="radio" id="payment_method_<?php echo $gateway->id; ?>" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php if ($gateway->chosen) echo 'checked="checked"'; ?> />
<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
<?php
if ( $gateway->has_fields() || $gateway->get_description() ) {
echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display:none;">';
$gateway->payment_fields();
echo '</div>';
}
?>
</li>
<?php
}
} else {
echo '<p>'.__( 'Sorry, it seems that there are no available payment methods for your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ).'</p>';
}
?>
</ul>
任何想法?谢谢