Â
- Click on the tab Sellers tools. Under the section Website preferences, click on Update.
Scroll down to the Auto return section. You need to turn on the Auto Return to enable the Payment Data Transfer feature.
After that, you will see a field where you can add your Return URL page. You need to choose this URL carefully because this is also the page where your customers will be sent to after they have completed their checkout process.
- Once adding the Return URL page, click on the button Save. Then, you just need to scroll down a little bit to access your PayPal Data Transfer token. You will need to turn this feature on and copy your *Identity token**.
- Now, from your WordPress admin dashboard, go to WooCommerce > Settings > Payments.
Then, click on Manage under the PayPal section to open your PayPal settings for WooCommerce.
Go to the section PayPal identity token and paste the Identity token that you have just copied in 6.
You also need to set up other PayPal settings here to offer your customers the best checkout experience possible. When you’re done, remember to click Save changes.
And that’s all you need to do to autocomplete WooCommerce orders.
Method 2: Using PHP code snippets
This technique is ideal for people who have coding skills but do not want to install any additional plugins on their site.
Step 1: Open Theme editor
First of all, from your WordPress dashboard, go to Appearance > Theme Editor to open your Theme editor.
After that, under the Theme files sidebar, you click on the Theme functions file on the far right.
This is your functions.php file, and it will allow you to add custom functions to your WordPress website.
Step 2: Paste the PHP code
Under the functions.php file, you paste the PHP code below to enable the autocompletion of orders for all of your WooCommerce virtual products.
get_status();
// We only want to update the status to 'completed' if it's coming from one of the following statuses:
$allowed_current_statuses = array( 'on-hold', 'pending', 'failed' );
if ( 'processing' === $payment_complete_status && in_array( $current_status, $allowed_current_statuses ) ) {
$order_items = $order->get_items();
// Create an array of products in the order
$order_products = array_filter( array_map( function( $item ) {
// Get associated product for each line item
return $item->get_product();
}, $order_items ), function( $product ) {
// Remove non-products
return !! $product;
} );
if ( count( $order_products > 0 ) ) {
// Check if each product is 'virtual'
$is_virtual_order = array_reduce( $order_products, function( $virtual_order_so_far, $product ) {
return $virtual_order_so_far && $product->is_virtual();
}, true );
if ( $is_virtual_order ) {
$payment_complete_status = 'completed';
}
}
}
return $payment_complete_status;
}
Step 3: Update file
Finally, click on Update file to finish the autocompletion of orders for virtual products.
And that’s how you autocomplete orders in WooCommerce using PHP code snippets.
Recommended Plugins to AutoComplete Orders in WooCommerce
In this part, we have compiled the four highly recommended plugins that could help you enable autocomplete WooCommerce orders. Let’s check them out!