php - WooCommerce 支付网关(全部)错误 - 类 wc-form-handler
问题描述
我可以让页面显示表单并拥有所有相关(我知道的)信息,但是提交时出现内部服务器错误,就好像我错过了一步!
根据最终客户的要求,我已将付款阶段分成 4 页。付款方式如下。网关是:
- 默认贝宝网关
- Stripe 官方网关
错误是({site} = 实际站点正常存在):
2019-02-23T14:04:10+00:00 严重未捕获的错误:调用 /var/www/vhosts/{site}/wp-content/plugins/woocommerce/includes/class 中布尔值的成员函数 get_id() -wc-form-handler.php:360 堆栈跟踪:#0 /var/www/vhosts/{site}/wp-includes/class-wp-hook.php(286):WC_Form_Handler::pay_action(Object(WP) ) #1 /var/www/vhosts/{site}/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /var/www/vhosts/{site} /wp-includes/plugin.php(531): WP_Hook->do_action(Array) #3 /var/www/vhosts/{site}/wp-includes/class-wp.php(750): do_action_ref_array('wp' , 数组) #4 /var/www/vhosts/{site}/wp-includes/functions.php(1105): WP->main('') #5 /var/www/vhosts/{site}/wp- blog-header.php(16): wp() #6 /var/www/vhosts/{site}/index.php(17): require('/var/www/vhosts...') #7 {main} 在第 360 行抛出 /var/www/vhosts/{site}/wp-content/plugins/woocommerce/includes/class-wc-form-handler.php
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
<?php
if ( ! is_ajax() ) {
do_action( 'woocommerce_review_order_before_payment' );
}
?>
<?php
$gateways = WC()->payment_gateways->get_available_payment_gateways();
$enabled_gateways = [];
if( $gateways ) {
foreach( $gateways as $gateway ) {
if( $gateway->enabled == 'yes' ) {
$enabled_gateways[] = $gateway;
}
}
}
?>
<div class="payment-methods">
<ul>
<?php
foreach($enabled_gateways as $get_gateway){
echo '<li>Pay with '.$get_gateway->title.'<div class="btn-group"><a href="#payment" class="button" onclick="loadMethod('.str_replace(' ', '_', $get_gateway->title).')">Pay by '.str_replace('Stripe', 'Card', $get_gateway->method_title).'</a></div>';
}
?>
</ul>
</div>
<div class="payment-container" id="payment">
<div class="checkout">
<?php foreach($enabled_gateways as $get_gateway): ?>
<?php #if($get_gateway->title != "PayPal"): ?>
<form name="checkout" method="post" class="checkout1" action="<?php echo esc_url( $get_checkout_url ); ?>" enctype="multipart/form-data">
<?php #wp_nonce_field( 'stripe' ); ?>
<input id="payment_method_<?php echo esc_attr( $get_gateway->id ); ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $get_gateway->id ); ?>" <?php checked( $get_gateway->chosen, true ); ?> data-order_button_text="<?php echo esc_attr( $get_gateway->order_button_text ); ?>" />
<input type="hidden" name="woocommerce_pay" value="1" />
<?php $get_gateway->payment_fields(); ?>
<?php wc_get_template( 'checkout/terms.php' ); ?>
<?php do_action( 'woocommerce_pay_order_before_submit' ); ?>
<?php
if($get_gateway->title == "PayPal"){
echo apply_filters( 'woocommerce_pay_order_button_html', '<button type="submit" class="button alt" id="place_order" value="' . esc_attr( $get_gateway->order_button_text ) . '" data-value="' . esc_attr( $get_gateway->order_button_text ) . '">' . esc_html( $get_gateway->order_button_text ) . '</button>' );
}
else{
#echo apply_filters( 'woocommerce_pay_order_button_html', '<button type="submit" class="button alt" id="place_order" value="Pay now" data-value="pay now">pay now</button>' );
echo '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="Place order" data-value="Place order">Place order</button>';
}
?>
<?php wp_nonce_field( 'woocommerce-pay', 'woocommerce-pay-nonce' ); ?>
<?php do_action( 'woocommerce_pay_order_after_submit' ); ?>
</form>
<?php #endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php
if ( ! is_ajax() ) {
do_action( 'woocommerce_review_order_after_payment' );
}
?>
解决方案
推荐阅读
- c++ - 我可以使用命名空间中的一些但不是全部名称,而不必为所有名称重复完整范围吗?
- json - Jolttransformjson 无法从多记录 json 文件中工作
- python - 如何在烧瓶表中制作具有相同文本的按钮?
- python - 为我的 shell 中的每个项目获取多个图像 url,但只为我的 csv 中的每个项目导入一个 url
- javascript - Upload a CSV file using AJAX in Django
- planning - PDDL2.1:“总体”的目的
- python - Plotly Sankey:如何避免将所有节点自动放置到右侧?
- vba - 如何从电子邮件线程的原始消息中获取详细信息?
- django - django 中的表单不保存在 Psql 中
- python - 我有一个数据集,其中列是 int 格式,但是当我执行 data.columns.dtype 时,它会显示 dtype('O')。如何将其更改为 int?