Migrate from WooCommerce API Manager ( or similar plugins ) to WP Software License

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

Migrating to the WooCommerce Software License plugin offers a host of benefits for your online store—most notably, a substantial boost in API processing speed. If you’re looking for an upgrade from the WooCommerce API Manager, this guide will walk you through the migration process while emphasizing the performance edge and reliability of the new plugin.

Why Switch to WooCommerce Software License?

One of the most compelling reasons to migrate is the exceptional API processing speed provided by the WooCommerce Software License plugin. Unlike the WooCommerce API Manager—and indeed, most other APIs on the market—the Software License solution has been engineered for rapid response times.  That has been achieved due to its light code and an included Cache Module, which can be easily activated through the plugin settings.  This efficiency not only enhances your user experience but also streamlines administrative tasks, reducing delays in license verification and activation. Faster API responses mean improved performance during peak traffic, ensuring that your customers experience seamless service even during high-demand periods.

In addition to speed, the WooCommerce Software License plugin offers improved stability and robust security features. By switching, you’re not only future-proofing your digital store but also ensuring that your licensing system is both scalable and reliable for the long haul.

Preparing for the Migration

Before initiating the migration process, ensure that you back up your current website and data. This precautionary step protects your valuable information and allows you to revert to a previous state should any unforeseen issues arise. It is also recommended that you review your server environment and PHP version compatibility to take full advantage of the enhanced API performance that the WooCommerce Software License plugin provides.

The Migration Process

Migrating from the WooCommerce API Manager to the WooCommerce Software License plugin is a straightforward process. Follow these steps carefully:

  1. Backup Your Data: Begin by creating a complete backup of your website, including the database and files. This step is crucial to prevent data loss during migration.
  2. Install the WooCommerce Software License Plugin: Download and install the new plugin via the WordPress dashboard. Make sure it is activated correctly.
  3. Setup the licensed Products: All products that use licensing should be filled in with appropriate data.
  4. Import Existing License Data: The migration process includes a PHP code snippet to help transfer your existing license data seamlessly.
  5. Test the New Setup: Once the migration is complete, run thorough tests to ensure that the API endpoints are performing as expected, particularly noting the remarkable speed improvements.

Below is the PHP code snippet provided by the plugin. Use this code as is during your migration process:

 

<?php
    
    include('wp-config.php');
    
    global $post, $WOO_SL, $wpdb;
    
    //fetch all orders
    $args   =   array(
                        'post_type'         =>  'shop_order',
                        'posts_per_page'    =>  -1,
                        'post_status'       =>  'any',
                        'fields'            =>  'ids',
                        'orderby'           =>  'ID',
                        'order'             =>  'DESC'
                        );
                        
    $custom_query       =   new WP_Query( $args );
    
    while( $custom_query->have_posts() )
        {
            $custom_query->the_post();
            
            //check if alreaady processed, in case the code previouslly timed out
            $woosl_migrate_processed    =   get_post_meta( $post, '_woosl_migrated', TRUE );
            if( ! empty($woosl_migrate_processed))
                continue;
            
            $order  =   new WC_Order( $post );
            
            //Add the licensing dataon order
            $WOO_SL->functions->order_setup_licensing( $post, array() );
            
            /**
            * 
            * Update the expiration as, by default, code use today 
            * @var mixed
            */
            $order_products =   $order->get_items();
            
            $found_licensed_product =   FALSE;
            foreach($order_products as  $key    =>  $order_product)
                {
                    if (WOO_SL_functions::is_product_licensed($order_product['product_id']))
                        {
                            $found_licensed_product =   TRUE;
                            break;   
                        }
                }
            
            // the order need at least one licensed item    
            if(!$found_licensed_product)
                {
                    //mark as processed
                    update_post_meta($post, '_woosl_migrated', 'true');
                    continue;
                }
                
            
            //get user data
            $user_licensing_data    =   get_user_meta( $order->get_user_id(), $wpdb->prefix . 'wc_am_orders', TRUE );
            
            //feetch the licences for current order
            $licences   =   array();
            foreach  ( $user_licensing_data  as $license_key    =>  $license_data )
                {
                    if ( $license_data['order_id']  !=  $order->get_ID() )
                        continue;
                        
                    $licences[ $license_key ]   =   $license_data;
                }
            
            if ( count ( $licences ) &lt; 1 )
                continue;
                
            
            /**
            * Always use the first group
            * 
            * @var mixed
            */
            $__licence_group_key    =   0; 
                
            foreach ( $order_products as $order_key   =>  $order_product ) 
                {
                    if(! $WOO_SL->functions->is_product_licensed($order_product['product_id']))
                        continue;    
                    
                    //insert the key
                    foreach  ( $licences  as $license_key    =>  $license_data )
                        {
                            $query = "INSERT INTO `" . $wpdb->prefix ."woocommerce_software_licence` 
                                            (`id`, `order_id`, `order_item_id`, `group_id`, `licence`, `created`, `active_domain`) 
                                            VALUES (NULL, ". $order->get_ID()  .", $order_key, ". $__licence_group_key .", '" . $license_key ."', '".$time."', NULL);";
                            $results = $wpdb->get_results($query);
                        }
       
       
       
       
       
                    $_woo_sl    =   WOO_SL_functions::get_order_item_meta( $order_key,  '_woo_sl',  TRUE);
                    if(!    is_array($_woo_sl))
                        continue;
   
                        
                    //check for different number of instances pe key
                    $_max_instances_per_key =   $_woo_sl['max_instances_per_key'][$__licence_group_key];
                    foreach ($licences as   $licence_data )
                        {
                            if ( $licence_data['_api_activations_parent']   >   $_max_instances_per_key )
                                $_max_instances_per_key =   $licence_data['_api_activations_parent'];
                        }
                    
                    $_woo_sl['max_instances_per_key'][$__licence_group_key] =   $_max_instances_per_key;
                    
                    wc_update_order_item_meta( $order_key, '_woo_sl', $_woo_sl);
                    
                    
                    
                    /**
                    * Mark the licence status as active if the order is completed
                    */
                    if ( $order->get_status()   ==  'completed' )
                        wc_update_order_item_meta( $order_key, '_woo_sl_licensing_status', 'active');
                        
                }    
            
            
            //mark as processed
            update_post_meta($post, '_woosl_migrated', 'true');
            
        }
                        
    
    echo "All Done";
    
?>

 

 

Additional Benefits

Beyond the superior API processing speed, the WooCommerce Software License plugin offers several other advantages over traditional API managers:

  • Enhanced Scalability: The plugin’s architecture is built to scale efficiently, accommodating growth in the number of API requests without sacrificing performance.
  • Streamlined License Management: With advanced features for license key generation, activation, and management, the new system simplifies administrative tasks and reduces overhead.
  • Robust Security: Improved encryption and secure API endpoints help protect your licenses and customer data, ensuring a safer transactional environment.
  • User-Friendly Interface: An intuitive backend interface minimizes the learning curve for administrators, making it easier to manage licenses even as your business grows.

Moreover, the enhanced processing speed of the WooCommerce Software License plugin means that your site can handle more simultaneous API calls with lower latency compared to the WooCommerce API Manager. This improvement is critical for businesses with high transaction volumes and customers who expect instantaneous responses.

Final Thoughts

Switching to the WooCommerce Software License plugin represents a smart investment in both performance and long-term reliability. With its industry-leading API processing speed and a suite of enhanced features, the migration process is an opportunity to boost the efficiency of your licensing operations. By following the steps outlined in this guide and utilizing the provided PHP code snippet without alterations, you can ensure a smooth transition and a more robust licensing system for your WooCommerce store.


Category:

By woocommerce-sl, posted on March 4, 2025

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments