• Resolved Albin

    (@albinvlc)


    Hello,

    I get the “Could not retrieve order” in /checkout page while I am doing a simple buy.

    Looking for it in the code I found it in OrderEndpoint and it happens because the url is being composed without the order id.

    $url = trailingslashit( $this->host ) . 'v2/checkout/orders/' . $id;

    Checking it with debug_backtrace I found that is being called from OrderProcessor

    $order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
    $order    = $this->session_handler->order() ?? $this->order_endpoint->order( $order_id );

    And so I knew that the meta is empty.

    The question is … Why? What is not happening?

    I found three points where the meta is updated. CreateOrderEndpoint, EarlyOrderHandler and OrderMetaTrait but … it’s for me impossible to guess or to find out which would be the right behaviour. What should have call what else in which moment…

    Can someone help me, please?

    • This topic was modified 2 years, 5 months ago by Albin.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @albinvlc,

    You’re looking in the wrong direction, as the Could not retrieve order. error usually occurs when clicking the “Place order” button from the PayPal gateway.
    This button is supposed to be hidden in favor of the smart buttons: https://woocommerce.com/document/woocommerce-paypal-payments/#paypal-on-checkout-page
    Clicking it will result in this error and a failed order.
    There is most likely a JavaScript error or a conflict with a different plugin preventing the plugin JavaScript from being executed and the smart buttons from loading.

    A full conflict test is the best way to rule out eventual issues with the theme or a different plugin. We recommend temporarily activating the default theme Storefront and disabling all other plugins except for?WooCommerce and?PayPal Payments to see if the behavior persists.

    Here’s a guide that explains the steps in more detail: How to test for conflicts
    https://woocommerce.com/document/woocommerce-paypal-payments/#troubleshooting
    Please let us know how this works out for you.
    Thanks!

    Kind regards,
    Niklas

    Thread Starter Albin

    (@albinvlc)

    Hello Niklas,

    I bet it works in Storefront but I expect that it works also in my theme as it has all the hooks, the same hooks that can be found in woocommerce templates folder.

    In payment.php I list the available gateways:

    foreach($available_gateways as $gateway) {
    	wc_get_template( 'checkout/payment-method.php', array('gateway'=>$gateway));
    }

    And in payment-method.php I let each gateway to put its own fields.

    <li class="wc_payment_method payment_method_<?php echo esc_attr( $gateway->id ); ?>">
    	<input id="payment_method_<?php echo esc_attr( $gateway->id ); ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> data-order_button_text="<?php echo esc_attr( $gateway->order_button_text ); ?>" />
    	<label for="payment_method_<?php echo esc_attr( $gateway->id ); ?>">
    		<?php echo $gateway->get_title(); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?> <?php // $gateway->get_icon(); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?>
    	</label>
    	<?php if(!empty($gateway->get_description())) : ?>
    		<? $gateway->payment_fields(); ?>
    	<?php endif; ?>
    </li>

    jQuery is available.

    Do you mean that the paypal gateway listed with this code should be hidden and a different button (smart button) should appear magically (for me) somewhere in the screen?

    That’s definitly not happening.

    Where could be the error? What js file is missing? Where is it registered? How can I register it?

    Let’s work together to fix it, please.

    Thanks
    – Mario

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @albinvlc,

    The purpose of changing the theme & disabling plugins is to isolate the cause for the behavior. The problem likely results from the plugin JavaScript not being executed, but there could be a million possible reasons for a problem like this.

    The smart buttons are supposed to look like this: https://woocommerce.com/document/woocommerce-paypal-payments/#customer-experience

    Where could be the error? What js file is missing? Where is it registered? How can I register it?

    You don’t need to register anything, as the integration is developed in a way that only requires you to connect an account with the onboarding wizard & the rest happens automatically.

    To better judge what could be causing the problem for you, we are interested in a copy of your WooCommerce system report and your latest PayPal Payments log files.
    The system report can be accessed from here:
    WooCommerce > Status > Get system report > Copy for support
    You can copy the log files from here (Logging must be enabled in the settings though):
    WooCommerce > Status > Logs > select “woocommerce-paypal-payments-[…]” in the dropdown and click on view.
    You can share it either here in the forums or privately with us from here:
    https://paypal.inpsyde.com/docs/request-support/
    Please include a link to this thread when sending a private message.
    Thanks!

    Kind regards,
    Niklas

    Thread Starter Albin

    (@albinvlc)

    Hello again Niklas,

    What I meant is that if your plugin needs a hook being called (like woocommerce_whatever) or a script being registered (like wp_enqueue_script(‘paypal_whatever’, ‘…’)), I will make sure that it happens.

    I want to do some test and if it keeps failing I resume this thread with the information you have requested.

    Thanks.

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    The plugin only must be connected to a PayPal account, and you need a WooCommerce checkout page built with the woocommerce_checkout shortcode. There is no need to enqueue any scripts yourself, even when building a custom theme. It’s meant to be as easy as can be, but it certainly is possible to potentially break it through a conflict.

    The most important script is probably the button.js. I can’t provide too many details, but just enqueueing this script is unlikely to resolve the problem though.
    It’s usually easier to find the issue if you start with a working setup, e.g., with only WooCommerce and the Storefront theme active, and then step by step enable your theme and potentially third-party plugins until the behavior breaks.
    If it’s the theme, then it requires further troubleshooting by disabling certain parts of the theme.
    If you could share a link to your site, we may also get a better idea about what could be causing the difficulty for you. But without seeing the issue, we can’t say too much about it.
    Thanks!

    Kind regards,
    Niklas

    Plugin Support Andreas W.

    (@aweissinpsyde)

    Hello,

    It has been quite some time since our last communication, so we will mark this thread as resolved. Please open a new thread if you are still facing issues or have questions that you need us to answer.

    Kind regards,
    Andreas

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘The meta _ppcp_paypal_order_id in WC_Order is empty’ is closed to new replies.