【发布时间】:2011-12-30 05:09:11
【问题描述】:
我一直在对 wordpress 电子商务插件进行一些更改,并且我已经提取了大量功能以使其更简单以满足我的需求。现在按下购买按钮后它不会重定向到感谢页面,因为该函数使用了一些我删除的变量,例如order_id等。
我已经为此工作了几个小时,我想要做的只是单击购买按钮重定向到thankyou.php。 (我现在知道它使用 ajax,我也不介意使用它)我不需要它来处理 processpayment 功能或类似的东西。真的很简单。
这是我正在使用的代码和函数:
非常感谢!!!
输入元素:
<div id="payment">
<div class="form-row">
<noscript><?php _e('Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'jigoshop'); ?><br/><input type="submit" class="button-alt" name="update_totals" value="<?php _e('Update totals', 'jigoshop'); ?>" /></noscript>
<?php jigoshop::nonce_field('process_checkout')?>
<input type="submit" class="button-alt" name="place_order" id="place_order" value="<?php _e('Next Step', 'jigoshop'); ?>" />
<?php do_action( 'jigoshop_review_order_before_submit' ); ?>
<?php if (get_option('jigoshop_terms_page_id')>0) : ?>
<p class="form-row terms">
<label for="terms" class="checkbox"><?php _e('I accept the', 'jigoshop'); ?> <a href="<?php echo get_permalink(get_option('jigoshop_terms_page_id')); ?>" target="_blank"><?php _e('terms & conditions', 'jigoshop'); ?></a></label>
<input type="checkbox" class="input-checkbox" name="terms" <?php if (isset($_POST['terms'])) echo 'checked="checked"'; ?> id="terms" />
</p>
<?php endif; ?>
<?php do_action( 'jigoshop_review_order_after_submit' ); ?>
</div>
</div>
checkout.class.php:
// Process Payment
$result = $available_gateways["cheque"]->process_payment( $order_id );
// Redirect to success/confirmation/payment page
if (is_ajax()) :
ob_clean();
echo json_encode($result);
exit;
else :
wp_safe_redirect( $result['redirect'] );
exit;
endif;
else :
// No payment was required for order
$order->payment_complete();
// Empty the Cart
jigoshop_cart::empty_cart();
// Redirect to success/confirmation/payment page
$checkout_redirect = apply_filters( 'jigoshop_get_checkout_redirect_page_id', get_option( 'jigoshop_thanks_page_id' ) );
if (is_ajax()) :
ob_clean();
echo json_encode( array( 'redirect' => get_permalink( $checkout_redirect ) ) );
exit;
else :
wp_safe_redirect( get_permalink( $checkout_redirect ) );
exit;
endif;
endif;
// Break out of loop
break;
处理支付功能:
function process_payment() {
// Remove cart
jigoshop_cart::empty_cart();
// Return thankyou redirect
$checkout_redirect = apply_filters( 'jigoshop_get_checkout_redirect_page_id', get_option( 'jigoshop_thanks_page_id' ) );
return array(
'result' => 'success',
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink( $checkout_redirect )))
);
}
这是我从 firebug 得到的错误详情:
打开调试后,出现以下错误:
注意:未定义索引:aiosp_enabled in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php 710号线
注意:未定义索引:aiosp_enabled in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php 710号线
注意:使用未定义的常量 PLUGIN_URL - 假定为“PLUGIN_URL” /home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php 在第 81 行
注意:使用未定义的常量 PLUGIN_PATH - 假定为“PLUGIN_PATH” 在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php 在第 82 行
注意:未定义的索引:主机在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jetpack/jetpack.php 2306行
注意:未定义索引:shipping-first_name in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 198 行
注意:未定义索引:shipping-last_name in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 199 行
注意:未定义索引:shipping-company in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 200 行
注意:未定义索引:送货地址在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 201行
注意:未定义索引:shipping-address-2 in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 202 行
注意:未定义索引:shipping-city in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 203 行
注意:未定义索引:shipping-state in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 204 行
注意:未定义索引:shipping-postcode in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 205 行
注意:未定义索引:shipping-country in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 206 行
重要提示:
注意:未定义变量:user_id in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 211行
注意:未定义索引:order_cmets in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 256 行
注意:未定义索引:billing-company in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 264 行
注意:未定义索引:帐单地址在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 265 行
注意:未定义索引:billing-address-2 in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 266 行
注意:未定义索引:billing-city in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 267 行
注意:未定义索引:billing-postcode in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第268行
注意:未定义索引:billing-country in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第 269 行
注意:未定义索引:帐单状态在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 270 行
注意:未定义索引:billing-phone in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 272 行
注意:未定义索引: shipping_method in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 282 行
注意:未定义索引:payment_method in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 283 行
注意:未定义索引:aiosp_edit in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php 1105行
注意:未定义索引:nonce-aioseop-edit in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php 1106行
重要提示:
注意:未定义变量:user_id in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 364 行
注意:未定义变量:available_gateways in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第 379 行
重要提示:
致命错误:调用成员函数 process_payment() 非对象在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第 379 行
注意:未定义索引:aiosp_enabled in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php 710号线
注意:未定义索引:aiosp_enabled in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php 710号线
注意:使用未定义的常量 PLUGIN_URL - 假定为“PLUGIN_URL” /home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php 在第 81 行
注意:使用未定义的常量 PLUGIN_PATH - 假定为“PLUGIN_PATH” 在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php 在第 82 行
注意:未定义的索引:主机在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jetpack/jetpack.php 2306行
注意:未定义索引:shipping-first_name in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 198 行
注意:未定义索引:shipping-last_name in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 199 行
注意:未定义索引:shipping-company in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 200 行
注意:未定义索引:送货地址在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 201行
注意:未定义索引:shipping-address-2 in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 202 行
注意:未定义索引:shipping-city in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 203 行
注意:未定义索引:shipping-state in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 204 行
注意:未定义索引:shipping-postcode in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 205 行
注意:未定义索引:shipping-country in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 206 行
注意:未定义变量:user_id in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 211行
注意:未定义索引:order_cmets in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 256 行
注意:未定义索引:billing-company in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 264 行
注意:未定义索引:帐单地址在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 265 行
注意:未定义索引:billing-address-2 in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 266 行
注意:未定义索引:billing-city in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 267 行
注意:未定义索引:billing-postcode in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第268行
注意:未定义索引:billing-country in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第 269 行
注意:未定义索引:帐单状态在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 270 行
注意:未定义索引:billing-phone in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 272 行
注意:未定义索引: shipping_method in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 282 行
注意:未定义索引:payment_method in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 283 行
注意:未定义索引:aiosp_edit in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php 1105行
注意:未定义索引:nonce-aioseop-edit in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php 1106行
注意:未定义变量:user_id in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 在第 364 行
注意:未定义变量:available_gateways in /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第 379 行
重要!!!!:
致命错误:调用成员函数 process_payment() 非对象在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php 第 379 行
注意:未定义索引:aiosp_enabled in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php 710号线
注意:未定义索引:aiosp_enabled in /home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php 710号线
注意:使用未定义的常量 PLUGIN_URL - 假定为“PLUGIN_URL” /home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php 在第 81 行
注意:使用未定义的常量 PLUGIN_PATH - 假定为“PLUGIN_PATH” 在 /home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php 在第 82 行
【问题讨论】:
-
您没有提供足够的信息来回答这个问题。
-
使用 FireBug 调试 ajax 请求 getfirebug.com 它应该会打印出出错信息。
-
@satrun77 jigoshop-checkout 功能出错。
-
@novicePrgrmr 您可以发布包含所有详细信息的完整错误消息。错误在哪个文件、行号、错误消息和来自 ajax 请求的响应文本。
-
@satrun77 完成。这就是我从萤火虫那里得到的