I have been making some changes to a wordpress ecommerce plugin and I’ve taken out a ton of functions to make it simpler for my needs. Now it won’t redirect to the thankyou page after the purchase button is pressed because the function uses some variables that I got rid of like order_id
, etc.
I’ve been working on this for a few hours now, and all I want it to do is redirect to thankyou.php on the click of the purchase button. (I know right now it uses ajax, and I wouldn’t mind using it too) I don’t need it to go to the processpayment function or anything like that. Really simple.
Here is the code and the functions that I’m working with:
Thanks so much!!!
Input element:
<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;
process payment function:
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 )))
);
}
Here is the error details I’m getting from firebug:
After I turned debugging on, I got these errors:
Notice: Undefined index: aiosp_enabled in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
on line 710Notice: Undefined index: aiosp_enabled in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
on line 710Notice: Use of undefined constant PLUGIN_URL – assumed ‘PLUGIN_URL’ in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php
on line 81Notice: Use of undefined constant PLUGIN_PATH – assumed ‘PLUGIN_PATH’
in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php
on line 82Notice: Undefined index: host in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jetpack/jetpack.php
on line 2306Notice: Undefined index: shipping-first_name in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 198Notice: Undefined index: shipping-last_name in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 199Notice: Undefined index: shipping-company in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 200Notice: Undefined index: shipping-address in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 201Notice: Undefined index: shipping-address-2 in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 202Notice: Undefined index: shipping-city in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 203Notice: Undefined index: shipping-state in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 204Notice: Undefined index: shipping-postcode in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 205Notice: Undefined index: shipping-country in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 206
IMPORTANT:
Notice: Undefined variable: user_id in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 211Notice: Undefined index: order_comments in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 256Notice: Undefined index: billing-company in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 264Notice: Undefined index: billing-address in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 265Notice: Undefined index: billing-address-2 in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 266Notice: Undefined index: billing-city in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 267Notice: Undefined index: billing-postcode in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 268Notice: Undefined index: billing-country in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 269Notice: Undefined index: billing-state in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 270Notice: Undefined index: billing-phone in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 272Notice: Undefined index: shipping_method in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 282Notice: Undefined index: payment_method in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 283Notice: Undefined index: aiosp_edit in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php
on line 1105Notice: Undefined index: nonce-aioseop-edit in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php
on line 1106
IMPORTANT:
Notice: Undefined variable: user_id in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 364Notice: Undefined variable: available_gateways in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 379
IMPORTANT:
Fatal error: Call to a member function process_payment() on a
non-object in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 379Notice: Undefined index: aiosp_enabled in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
on line 710Notice: Undefined index: aiosp_enabled in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
on line 710Notice: Use of undefined constant PLUGIN_URL – assumed ‘PLUGIN_URL’ in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php
on line 81Notice: Use of undefined constant PLUGIN_PATH – assumed ‘PLUGIN_PATH’
in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php
on line 82Notice: Undefined index: host in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jetpack/jetpack.php
on line 2306Notice: Undefined index: shipping-first_name in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 198Notice: Undefined index: shipping-last_name in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 199Notice: Undefined index: shipping-company in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 200Notice: Undefined index: shipping-address in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 201Notice: Undefined index: shipping-address-2 in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 202Notice: Undefined index: shipping-city in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 203Notice: Undefined index: shipping-state in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 204Notice: Undefined index: shipping-postcode in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 205Notice: Undefined index: shipping-country in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 206Notice: Undefined variable: user_id in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 211Notice: Undefined index: order_comments in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 256Notice: Undefined index: billing-company in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 264Notice: Undefined index: billing-address in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 265Notice: Undefined index: billing-address-2 in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 266Notice: Undefined index: billing-city in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 267Notice: Undefined index: billing-postcode in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 268Notice: Undefined index: billing-country in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 269Notice: Undefined index: billing-state in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 270Notice: Undefined index: billing-phone in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 272Notice: Undefined index: shipping_method in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 282Notice: Undefined index: payment_method in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 283Notice: Undefined index: aiosp_edit in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php
on line 1105Notice: Undefined index: nonce-aioseop-edit in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php
on line 1106Notice: Undefined variable: user_id in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 364Notice: Undefined variable: available_gateways in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 379
IMPORTANT!!!!:
Fatal error: Call to a member function process_payment() on a
non-object in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/jigoshop/classes/jigoshop_checkout.class.php
on line 379Notice: Undefined index: aiosp_enabled in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
on line 710Notice: Undefined index: aiosp_enabled in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
on line 710Notice: Use of undefined constant PLUGIN_URL – assumed ‘PLUGIN_URL’ in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php
on line 81Notice: Use of undefined constant PLUGIN_PATH – assumed ‘PLUGIN_PATH’
in
/home2/findmyki/public_html/bolistylus/wp-content/plugins/wp-google-fonts/google-fonts.php
on line 82
There should be some text or json string in the response tab, but it’s empty. This could be a result of php error that is hidden because of php settings in your server is set to hide all error messages, which is good.
Turn the debugging on see http://codex.wordpress.org/Editing_wp-config.php#Debug and try again. There should be some text in the response tab.
Update turn debugging on:
Something does not look right here. Do you get these errors when you send the Ajax request?
Looking at these errors I can see you have fatal error which must have stopped the code execution.
You have modified the original file jigoshop_checkout.class.php so it is hard for me to find the exact lines for these errors. But “Notice: Undefined index: ” means there is an array variable in that line does not have an index of…
The method ‘process_payment’ called once in this file
$available_gateways is an array with objects of different payment methods. But there is no object for the payment method defined in $this->posted[‘payment_method’]
Also, I can see there is another error message state that the variable $available_gateways does not exists/defined
This variable can only be defined when jigoshop_cart::needs_payment() return true
If you don’t need it to do anything else try that. You may need to edit the href to go where you want it to go. It worked for me on my site.
Also you can always have the action of the form redirect to another page then that page redirects to thank you page after processing.
Just use header(‘Location: ‘); to redirect.