yanping
Forum Replies Created
-
i can not be sure but we noticed the problem after updating to WordPress 6. It was in a customized woocommerce category page where wp_redirect is used for certain categories. I turned off wp-optimize cache for these categories for now. I also tried html redirect instead of wp_redirect and it worked but I don’t like the browser flashing.
I figured it out, the error was caused by a filter function I implemented that only worked for paypal express gateway that paypal made up to switch to last year.
I hard-coded
header( “Location: https://www.google.com”);
for testing paypal-standard redirect
in function process_order_payment in file class-wc-checkout.phpand it did not work. A blank error message showed up in check-out page.
This is my local test server:
### WordPress Environment ### WordPress address (URL): https://192.168.5.121/WP-Store Site address (URL): https://192.168.5.121/WP-Store WC Version: 5.9.0 REST API Version: ? 5.9.0 WC Blocks Version: ? 6.1.0 Action Scheduler Version: ? 3.3.0 WC Admin Version: ? 2.8.0 Log Directory Writable: ? WP Version: 5.8.1 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: ? Language: en_US External object cache: –
————————–
//I think the problem is at function process_order_payment in class-wc-checkout.php$result = apply_filters( ‘woocommerce_payment_successful_result’, $result, $order_id );
//as function wp_doing_ajax exists, is_ajax() below returns true
if ( ! is_ajax() ) {
// phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
wp_redirect( $result[‘redirect’] );
exit;
}//Causing SyntaxError: Unexpected token A in JSON at position 0 as $result is an array not a valid json string.
wp_send_json( $result );I have the same problem.
It is for order item attributes.
The recommended “woocommerce_new_order_item” does not work…or the data-structure for order-item attributes have completely changes….