{"id":963,"date":"2021-02-16T08:20:14","date_gmt":"2021-02-16T14:20:14","guid":{"rendered":"https:\/\/easydigitaldownloads.com\/development\/?p=963"},"modified":"2021-02-16T08:25:09","modified_gmt":"2021-02-16T14:25:09","slug":"edd-3-0-beta1","status":"publish","type":"post","link":"https:\/\/easydigitaldownloads.com\/development\/2021\/02\/16\/edd-3-0-beta1\/","title":{"rendered":"Easy Digital Downloads 3.0-beta1 now ready for testing"},"content":{"rendered":"\n<p>We&#8217;re pleased to announce that the first beta for Easy Digital Downloads 3.0 is now available! This has been a long time coming, and we want to thank you all for your patience and understanding while it&#8217;s been in development.<\/p>\n\n\n\n<p><strong>Important Note:<\/strong> This beta release is NOT production ready. It should only be tested on development sites. Do not install it on your live site.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Our goals for the first 3.0 beta<\/h2>\n\n\n\n<p>Easy Digital Downloads 3.0 is not yet a finished product. The point of this first beta release is not to test the plugin as a whole, but to focus on these key things:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Early testing on our migration process, to ensure all necessary data is migrated to its new place and that there are no issues with the data transfer or backwards compatibility.<\/li><li>Giving third party developers a chance to see how the code base has changed in 3.0, and the opportunity to update their extensions to be compatible.<\/li><\/ol>\n\n\n\n<p><strong>Official extensions that are compatible with 3.0:<\/strong><\/p>\n\n\n\n<p>The following extensions have been already updated to work with 3.0 and may be used in testing:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Auto Register, version 1.3.11+<\/li><li>Braintree Gateway, version 1.1.6+<\/li><li>Commissions, version 3.4.11+<\/li><li>Gateway Fees<\/li><li>PDF Invoices, version 2.2.27+<\/li><li>Recurring, version 2.10.1+<\/li><li>Software Licensing, version 3.7+<\/li><li>Stripe Gateway, version 2.8+<br><em>* When checking out with Stripe, you may see a debug notice about addresses being stored incorrectly. This will be addressed in version 2.8.1.<\/em><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">What&#8217;s not ready for testing<\/h3>\n\n\n\n<p>Order refunds are still undergoing some changes, particularly with regards to refunding fees, so we do not recommend testing refunds or updating any of your own refund-related code. We hope for this to be ready for the beta2 release.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">System requirements<\/h2>\n\n\n\n<p>In order to run EDD 3.0 you&#8217;ll need to have the following minimum versions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>PHP 5.6+<\/li><li>WordPress 4.9+<\/li><\/ul>\n\n\n\n<p>Note: If you installed EDD 3.0 back in 2018 <em>but have not pulled the release branch since then<\/em>, we recommend starting with an entirely fresh install. This is because we&#8217;ve removed some incremental database upgrades from the 3.0 development branch that were introduced in 2018. If you&#8217;re installing or upgrading to 3.0 for the first time then this does not affect you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing 3.0-beta1<\/h2>\n\n\n\n<p>The 3.0 beta release can be <a href=\"https:\/\/github.com\/easydigitaldownloads\/easy-digital-downloads\/releases\/download\/3.0-beta1\/easy-digital-downloads.zip\" target=\"_blank\" rel=\"noreferrer noopener\">downloaded from GitHub<\/a> and installed as normal. After installation, new database tables will be installed in the background and you will be prompted to run the 3.0 migration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the custom tables migration<\/h2>\n\n\n\n<p>In 3.0 we migrate the bulk of EDD data out of the WordPress core tables (posts, postmeta, etc.) and into our new custom tables. This includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Discounts<\/li><li>Payments<\/li><li>Customer addresses<\/li><li>Customer email addresses<\/li><li>Logs<\/li><li>Order notes<\/li><li>Customer notes<\/li><\/ul>\n\n\n\n<p>The migration can either be performed through an admin UI, or run through WP-CLI using this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp edd v30_migration<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"817\" height=\"516\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2021\/02\/edd3-migration.png\" alt=\"EDD 3.0 migration UI\" class=\"wp-image-980\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2021\/02\/edd3-migration.png 817w, https:\/\/easydigitaldownloads.com\/development\/files\/2021\/02\/edd3-migration-300x189.png 300w, https:\/\/easydigitaldownloads.com\/development\/files\/2021\/02\/edd3-migration-768x485.png 768w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/figure><\/div>\n\n\n\n<p>While testing the migration, double check that all your data has been migrated successfully and that none has been lost &#8212; this is particularly true of any custom data you may have added.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Custom payment meta to watch out for<\/h3>\n\n\n\n<p><strong>_edd_payment_meta<\/strong><\/p>\n\n\n\n<p>If you&#8217;ve added any custom keys to the <code>_edd_payment_meta<\/code> array then those will be inserted into our new <code>wp_edd_ordermeta<\/code> table using the key <code>payment_meta<\/code>. Just like before, this will be saved as a serialized array.<\/p>\n\n\n\n<p>Note: Calls to <code>edd_get_payment_meta( $payment_id, '_edd_payment_meta' )<\/code> are still fully backwards compatible and will include your custom keys\/values. However, the backwards compatibility layers do mean that this old method will be slower than our newer <code>edd_get_order_meta()<\/code> functions so we recommend updating if possible.<\/p>\n\n\n\n<p><strong>Cart item options<\/strong><\/p>\n\n\n\n<p>In 2.9, <code>_edd_payment_meta<\/code> included an array that looked like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array(\n    'cart_details' => array(\n        array(\n            'item_number' => array(\n                'options' => array(\n                    'price_id' => 1,\n                    'quantity' => 1,\n                    \/\/ More\n                )\n            )\n        )\n    )\n)<\/code><\/pre>\n\n\n\n<p>Any keys added to that <code>options<\/code> array will be migrated to our new <code>wp_edd_order_itemmeta<\/code> table. This is meta associated with an individual order item, rather than the order as a whole.<\/p>\n\n\n\n<p>Note: Retrieving this information via <code>edd_get_payment_meta()<\/code> or <code>edd_get_payment_meta_cart_details()<\/code> is still fully backwards compatible in 3.0. However, the backwards compatibility layers do mean that this old method will be slower than our newer <code>edd_get_order_meta()<\/code> functions so we recommend updating if possible.<\/p>\n\n\n\n<p><strong>Custom meta keys<\/strong><\/p>\n\n\n\n<p>Any custom pieces of meta data associated with a payment will be transferred exactly over to our new <code>wp_edd_ordermeta<\/code> table. Only the storage location has changed; the data and format remains exactly the same.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Updating your integrations for 3.0<\/h2>\n\n\n\n<p>Plugins can be compatible with both EDD 2.9 and 3.0 at the same time. However, a few methods are no longer compatible with 3.0 and your code may need to be updated accordingly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Ensure you&#8217;re not using &#8220;post&#8221; helper functions on payments, discounts, or logs<\/h3>\n\n\n\n<p>In 3.0 you can no longer use &#8220;post&#8221;-related helper functions on payment, log, or discount code objects. This includes <code>get_post()<\/code>, <code>get_post_meta()<\/code>, and more. You will need to update your code to use our wrapper functions instead.<\/p>\n\n\n\n<p>Here&#8217;s a detailed list of examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#payments-changes\">Payments<\/a><\/li><li><a href=\"#discounts-changes\">Discounts<\/a><\/li><li><a href=\"#logs-changes\">Logs<\/a><\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"payments-changes\">Payments\/orders<\/h4>\n\n\n\n<p>Note: in 3.0, payments are now referred to as &#8220;orders&#8221;, which is reflected in the new function names.<\/p>\n\n\n\n<p><strong>Retrieving a payment\/order<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\n$payment = get_post( $payment_id );\n\n\/\/ Valid in both 2.9 and 3.0\n$payment = edd_get_payment( $payment_id );\n\n\/\/ Valid in 3.0 only\n$payment = edd_get_order( $payment_id );<\/code><\/pre>\n\n\n\n<p><strong>Retrieving meta attached to a payment\/order<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\n$meta = get_post_meta( $payment_id, 'your_meta_key_here', true );\n\n\/\/ Valid in both 2.9 and 3.0\n$meta = edd_get_payment_meta( $payment_id, 'your_meta_key_here', true );\n\n\/\/ Valid in 3.0 only\n$meta = edd_get_order_meta( $payment_id, 'your_meta_key_here', true );<\/code><\/pre>\n\n\n\n<p><strong>Adding or updating payment\/order meta<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\nupdate_post_meta( $payment_id, 'your_meta_key_here', 'your meta value' );\n\n\/\/ Valid in both 2.9 and 3.0\nedd_update_payment_meta( $payment_id, 'your_meta_key_here', 'your meta value' );\n\n\/\/ Valid in 3.0 only\nedd_update_order_meta( $payment_id, 'your_meta_key_here', 'your meta value' );<\/code><\/pre>\n\n\n\n<p><strong>Querying for payment\/order records<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\n$payments = get_posts( array(\n    'post_type'   => 'edd_payment',\n    'post_status' => 'publish'\n) );\n\n\/\/ NO LONGER VALID\n$payments = new WP_Query( ( array(\n    'post_type'   => 'edd_payment',\n    'post_status' => 'publish'\n) );\n\n\/\/ Valid in both 2.9 and 3.0\n$payments = edd_get_payments( array(\n    'status' => 'publish'\n) );\n\n\/\/ Valid in 3.0 only\n$payments = edd_get_orders( array(\n    'status' => 'complete'\n) );<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"discounts-changes\">Discounts<\/h4>\n\n\n\n<p><strong>Retrieving a discount code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\n$discount = get_post( $discount_id );\n\n\/\/ Valid in both 2.9 and 3.0\n\/\/ Get by ID\n$discount = edd_get_discount( $discount_id );\n\n\/\/ Get by code\n$discount = edd_get_discount_by_code( 'BFCM2021' );<\/code><\/pre>\n\n\n\n<p><strong>Querying for discount codes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\n$discounts = get_posts( array(\n    'post_type'   => 'edd_discount',\n    'post_status' => array( 'active', 'inactive' )\n) );\n\n\/\/ Valid in both 2.9 and 3.0\n$discounts = edd_get_discounts( array(\n    'post_status' => array( 'active', 'inactive' )\n) );<\/code><\/pre>\n\n\n\n<p><strong>Retrieving meta attached to a discount<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\n$meta = get_post_meta( $discount_id, 'your_meta_key_here', true );\n\n\/\/ Valid in both 2.9 and 3.0\n$discount = edd_get_discount( $discount_id );\n$discount->get_meta( 'your_meta_key_here', true );\n\n\/\/ Valid in 3.0 only\nedd_get_adjustment_meta( $discount_id, 'your_meta_key_here', true );<\/code><\/pre>\n\n\n\n<p><strong>Adding or updating meta<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ NO LONGER VALID\nupdate_post_meta( $discount_id, 'your_meta_key_here', 'your meta value' );\n\n\/\/ Valid in both 2.9 and 3.0\n$discount = edd_get_discount( $discount_id );\n$discount->update_meta( 'your_meta_key_here', 'your meta value' );\n\n\/\/ Valid in 3.0 only\nedd_update_adjustment_meta( $discount_id, 'your_meta_key_here', 'your meta value' );<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"logs-changes\">Logs<\/h4>\n\n\n\n<p>EDD has a class called <code>EDD_Logging<\/code>, which is available in 2.9 and fully backwards compatible in 3.0. If your code needs to be compatible with both versions, ensure you use this class for all querying and inserting.<\/p>\n\n\n\n<p><strong>Querying logs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global $edd_logs;\n$edd_logs->get_logs( $object_id, $log_type, $page_number );<\/code><\/pre>\n\n\n\n<p><strong>Inserting a log:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global $edd_logs;\n$edd_logs->insert( array(\n    'log_type'    => 'gateway_error',\n    'post_parent' => $download_id\n) );<\/code><\/pre>\n\n\n\n<p>EDD 3.0 also comes with several new functions. Logs are split up into different database tables according to type: file download logs, API request logs, and generic logs. Here are the new functions for generic logs:<\/p>\n\n\n\n<p><strong>Querying logs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$logs = edd_get_logs( array(\n    'type'    => 'gateway_error',\n    'user_id' => $user_id\n) );<\/code><\/pre>\n\n\n\n<p><strong>Inserting a log:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>edd_add_log( array(\n    'object_id'   => $object_id,\n    'object_type' => $object_type,\n    'user_id'     => $user_id,\n    'type'        => $log_type,\n    'title'       => $log_title,\n    'content'     => $log_content\n) );<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Update raw queries on the wp_posts database table<\/h3>\n\n\n\n<p>In 3.0, most data has been migrated out of wp_posts and wp_postmeta. As a result, if you&#8217;re performing any raw queries on those tables, you may need to update your integration to query on our new tables instead in 3.0.<\/p>\n\n\n\n<p>Here&#8217;s a before and after example of one of our own queries for download logs:<\/p>\n\n\n\n<p><strong>2.9 query on the posts\/postmeta tables<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT post_parent as downloaded_product_id, COUNT(post_parent) AS number_of_downloads, COUNT(DISTINCT meta_value) AS unique_passes_used\nFROM {$wpdb->posts} p\nLEFT JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID\nWHERE meta_key = '_edd_log_all_access_pass_id'\nAND meta_value LIKE '%_{$all_access_product_id}_%'\nAND post_date_gmt > %s\nAND post_date_gmt &lt; %s\nGROUP BY post_parent\nORDER BY COUNT(post_parent) DESC;<\/code><\/pre>\n\n\n\n<p><strong>3.0 query on the file_downloads\/file_downloadmeta tables:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT product_id as downloaded_product_id, COUNT(product_id) as number_of_downloads, COUNT(DISTINCT meta_value) as unique_passes_used\nFROM {$wpdb->edd_logs_file_downloads} l\nINNER JOIN {$wpdb->edd_logs_file_downloadmeta} lm ON l.id = lm.edd_logs_file_download_id\nWHERE meta_key = '_edd_log_all_access_pass_id'\nAND meta_value LIKE '%_{$all_access_product_id}_%'\nAND date_created > %s\nAND date_created &lt; %s\nGROUP BY product_id\nORDER BY COUNT(product_id) DESC<\/code><\/pre>\n\n\n\n<p>With custom queries like this, you will need to load one version if the site is running EDD 2.9 or lower, and another version if the site is running 3.0+.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reporting issues<\/h2>\n\n\n\n<p>EDD 3.0 is still in active development on GitHub. If you encounter any bugs, please <a href=\"https:\/\/github.com\/easydigitaldownloads\/easy-digital-downloads\/issues\">search through our existing issues<\/a>. If there&#8217;s not already an open issue, you may create a new one (after reading our <a href=\"https:\/\/github.com\/easydigitaldownloads\/easy-digital-downloads\/blob\/master\/CONTRIBUTING.md\">Contributor Guidelines<\/a>). Please prefix all issues with &#8220;3.0 -&#8221; so we know it pertains to the 3.0 release.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re pleased to announce that the first beta for Easy Digital Downloads 3.0 is now available! This has been a long time coming, and we want to thank you all for your patience and understanding&#8230;<\/p>\n<p class=\"continue-reading\"><a class=\"more-link\" href=\"https:\/\/easydigitaldownloads.com\/development\/2021\/02\/16\/edd-3-0-beta1\/\">Continue reading &rarr;<\/a><\/p>\n","protected":false},"author":2782,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[17],"class_list":["post-963","post","type-post","status-publish","format-standard","hentry","category-core","tag-3dd"],"_links":{"self":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/users\/2782"}],"replies":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/comments?post=963"}],"version-history":[{"count":10,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/963\/revisions"}],"predecessor-version":[{"id":1003,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/963\/revisions\/1003"}],"wp:attachment":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/media?parent=963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/categories?post=963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/tags?post=963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}