woocommerce / woocommerce-paypal-payments

https://wordpress.org/plugins/woocommerce-paypal-payments/
GNU General Public License v2.0
61 stars 47 forks source link

error log ... /order-functions.php:38 #2318

Closed danosterhout closed 1 month ago

danosterhout commented 1 month ago

[05-Jun-2024 23:35:32 UTC] PHP Fatal error: Uncaught InvalidArgumentException: PayPal order ID not found in meta. in /wp-content/plugins/woocommerce-paypal-payments/api/order-functions.php:38 Stack trace:

0 /wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-order-tracking/src/Integration/ShipmentTrackingIntegration.php(88): WooCommerce\PayPalCommerce\Api\ppcp_get_paypal_order('')

1 /home/dollar42/d3creation.com/wp-includes/class-wp-hook.php(324): WooCommerce\PayPalCommerce\OrderTracking\Integration\ShipmentTrackingIntegration->WooCommerce\PayPalCommerce\OrderTracking\Integration{closure}('')

2 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)

3 /wp-includes/plugin.php(517): WP_Hook->do_action(Array)

4 /wp-admin/admin-ajax.php(192): do_action('wp_ajax_wc_ship...')

5 {main}

thrown in /wp-content/plugins/woocommerce-paypal-payments/api/order-functions.php on line 38

dream-encode commented 1 month ago

Came to report the same issue. Plugin version is 2.7.1. PHP 8.2.19.

For use, this error is triggered when we export order updates from ShipStation, and is causing the tracking to added to the order multiple(sometimes dozens of) times.

sargon1404 commented 1 month ago

For those looking for a quick fix: open file modules/ppcp-order-tracking/src/Integration/ShipmentTrackingIntegration.php and add this code at about line 86:

$payment_method = $wc_order->get_payment_method();
if ($payment_method != 'ppcp-gateway') {
    return;
}

It should look like this:

$order_id = (int) wc_clean( wp_unslash( $_POST['order_id'] ?? '' ) );
$wc_order = wc_get_order( $order_id );
if ( ! is_a( $wc_order, WC_Order::class ) ) {
    return;
}

//the new code
$payment_method = $wc_order->get_payment_method();
if ($payment_method != 'ppcp-gateway') {
    return;
}
//end

$paypal_order    = ppcp_get_paypal_order( $wc_order );
$capture_id      = $this->get_paypal_order_transaction_id( $paypal_order );
InpsydeNiklas commented 1 month ago

Hi folks, thanks for the issue report, and I apologize for the trouble. This error was resolved in https://github.com/woocommerce/woocommerce-paypal-payments/pull/2289. It can be worked around either with a temporary downgrade to version 2.7.0 or by installing the latest pre-release version for the upcoming 2.8.0 update.

If you need additional guidance on how to resolve the error, I recommend contacting our support team directly from here: https://woocommerce.com/document/woocommerce-paypal-payments/#get-help Thank you!