Changeset 3251915
- Timestamp:
- 03/06/2025 11:27:37 PM (13 months ago)
- Location:
- subscriptions-for-woo
- Files:
-
- 44 added
- 11 edited
-
tags/2.4.7 (added)
-
tags/2.4.7/autoload.php (added)
-
tags/2.4.7/classes (added)
-
tags/2.4.7/classes/PPSFWOO (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-ajax-actions-priv.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-ajax-actions.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-database.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-exception.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-order.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-pay-pal.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-plan.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-plugin-main.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-product.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-subscriber.php (added)
-
tags/2.4.7/classes/PPSFWOO/class-ppsfwoo-webhook.php (added)
-
tags/2.4.7/css (added)
-
tags/2.4.7/css/frontend.css (added)
-
tags/2.4.7/css/frontend.min.css (added)
-
tags/2.4.7/css/style.css (added)
-
tags/2.4.7/css/style.min.css (added)
-
tags/2.4.7/js (added)
-
tags/2.4.7/js/get-sub.js (added)
-
tags/2.4.7/js/get-sub.min.js (added)
-
tags/2.4.7/js/main.js (added)
-
tags/2.4.7/js/main.min.js (added)
-
tags/2.4.7/js/paypal-button.js (added)
-
tags/2.4.7/js/paypal-button.min.js (added)
-
tags/2.4.7/license.txt (added)
-
tags/2.4.7/readme.txt (added)
-
tags/2.4.7/subscriptions-for-woo.php (added)
-
tags/2.4.7/templates (added)
-
tags/2.4.7/templates/edit-user.php (added)
-
tags/2.4.7/templates/options-page.php (added)
-
tags/2.4.7/templates/paypal-button.php (added)
-
tags/2.4.7/templates/subscriber-table-settings-page.php (added)
-
tags/2.4.7/templates/tab-content (added)
-
tags/2.4.7/templates/tab-content/go-pro.php (added)
-
tags/2.4.7/templates/tab-content/tab-advanced.php (added)
-
tags/2.4.7/templates/tab-content/tab-general.php (added)
-
tags/2.4.7/templates/tab-content/tab-plans.php (added)
-
tags/2.4.7/templates/tab-content/tab-subscribers.php (added)
-
tags/2.4.7/templates/table-plans.php (added)
-
tags/2.4.7/templates/table-webhooks.php (added)
-
tags/2.4.7/templates/thank-you.php (added)
-
trunk/classes/PPSFWOO/class-ppsfwoo-ajax-actions-priv.php (modified) (3 diffs)
-
trunk/classes/PPSFWOO/class-ppsfwoo-ajax-actions.php (modified) (1 diff)
-
trunk/classes/PPSFWOO/class-ppsfwoo-database.php (modified) (2 diffs)
-
trunk/classes/PPSFWOO/class-ppsfwoo-order.php (modified) (4 diffs)
-
trunk/classes/PPSFWOO/class-ppsfwoo-pay-pal.php (modified) (1 diff)
-
trunk/classes/PPSFWOO/class-ppsfwoo-plan.php (modified) (3 diffs)
-
trunk/classes/PPSFWOO/class-ppsfwoo-plugin-main.php (modified) (6 diffs)
-
trunk/js/main.js (modified) (1 diff)
-
trunk/js/main.min.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/subscriptions-for-woo.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-ajax-actions-priv.php
r3243512 r3251915 34 34 public static function refresh_plans() 35 35 { 36 $wait = 10; 37 38 if(true === get_transient('ppsfwoo_refresh_plans_ran')) { 39 40 return wp_json_encode([ 41 'error' => 'Please wait at least ' . absint($wait) . ' seconds and try again.' 42 ]); 43 44 } 45 36 46 if(!is_super_admin() && !current_user_can('ppsfwoo_manage_settings')) { 37 47 … … 42 52 } 43 53 54 set_transient('ppsfwoo_refresh_plans_ran', true, $wait); 55 44 56 $Plan = new Plan(); 45 57 … … 48 60 return wp_json_encode([ 49 61 "success" => !empty($plans), 50 " plans" => $plans62 "length" => sizeof($plans) 51 63 ]); 52 64 } -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-ajax-actions.php
r3251356 r3251915 57 57 $plan_id = get_post_meta($product_id, "{$PluginMain->env['env']}_ppsfwoo_plan_id", true) ?? NULL; 58 58 59 $Plan = isset($product_id ) ? new Plan($plan_id): NULL;59 $Plan = isset($product_id, $plan_id) ? new Plan($plan_id): NULL; 60 60 61 if(isset($Plan) && $Plan->id) {61 if(isset($Plan)) { 62 62 63 63 $response = [ -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-database.php
r3251356 r3251915 46 46 public static function install() 47 47 { 48 if((new self("SHOW TABLES LIKE '{$GLOBALS['wpdb']->base_prefix}ppsfwoo_subscriber';"))->result) 49 50 return; 51 48 52 new self("CREATE TABLE IF NOT EXISTS {$GLOBALS['wpdb']->base_prefix}ppsfwoo_subscriber ( 49 53 id varchar(64) NOT NULL, … … 75 79 $this_version = PluginMain::plugin_data('Version'); 76 80 77 if($installed_version === $this_version) { 78 79 return; 80 81 } 81 if($installed_version === $this_version) return; 82 82 83 83 if (version_compare($installed_version, '2.4.1', '<')) { -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-order.php
r3251356 r3251915 94 94 $item = new \WC_Order_Item_Product(); 95 95 96 if(1 === $sequence) { 97 98 $start_time = (new \DateTime(self::$Subscriber->subscription->start_time))->format('l, F j, Y'); 99 100 $name = " $name starts $start_time"; 101 102 } 103 96 104 $item->set_name($name); 97 105 … … 226 234 } 227 235 228 private static function set_taxes($item) 229 { 230 $taxes = \WC_Tax::get_rates_for_tax_class(self::$tax_rate_data['tax_rate_slug']); 236 public static function set_taxes($item, $tax_rate_data = NULL) 237 { 238 $tax_rate_data = $tax_rate_data ?? self::$tax_rate_data; 239 240 $taxes = \WC_Tax::get_rates_for_tax_class($tax_rate_data['tax_rate_slug']); 231 241 232 242 $found_rate = NULL; 233 243 234 if( self::$tax_rate_data['tax_rate'] === 0 || !empty(self::$tax_rate_data['inclusive']) || !$taxes)244 if($tax_rate_data['tax_rate'] === 0 || !empty($tax_rate_data['inclusive']) || !$taxes) 235 245 { 236 246 $item->set_tax_class(""); … … 241 251 foreach ($taxes as $tax_rate_object) 242 252 { 243 if( self::$tax_rate_data['tax_rate'] === $tax_rate_object->tax_rate) {253 if($tax_rate_data['tax_rate'] === $tax_rate_object->tax_rate) { 244 254 245 255 $found_rate = $tax_rate_object; … … 271 281 $subtotal_taxes = \WC_Tax::calc_tax($item->$get_subtotal(), $tax_rates, false); 272 282 273 $item->set_tax_class( self::$tax_rate_data['tax_rate_slug']);283 $item->set_tax_class($tax_rate_data['tax_rate_slug']); 274 284 275 285 $item->set_taxes([ -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-pay-pal.php
r3248728 r3251915 115 115 $args = [ 116 116 'method' => $method, 117 'timeout' => 10, 117 118 'headers' => array_merge([ 118 119 'Authorization' => 'Bearer ' . $token, -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-plan.php
r3251364 r3251915 173 173 foreach($plan_data['response']['plans'] as $plan) 174 174 { 175 if($PluginMain ->ppsfwoo_hide_inactive_plans&& "ACTIVE" !== $plan['status']) {175 if($PluginMain::get_option('ppsfwoo_hide_inactive_plans') && "ACTIVE" !== $plan['status']) { 176 176 177 177 continue; … … 183 183 $product_data = PayPal::request(PayPal::EP_PRODUCTS . $plan['product_id']); 184 184 185 $product_name = $product_data['response']['name'] ;185 $product_name = $product_data['response']['name'] ?? ""; 186 186 187 187 $products[$plan['product_id']] = $product_name; … … 223 223 ]); 224 224 225 return $ plans;225 return $PluginMain::get_option('ppsfwoo_plans'); 226 226 } 227 227 -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-plugin-main.php
r3248728 r3251915 57 57 'name' => 'Hide inactive plans', 58 58 'type' => 'checkbox', 59 'default' => 0,59 'default' => 1, 60 60 'description' => 'Choose to show/hide inactive PayPal plans on the Plans tab.', 61 61 'sanitize_callback' => 'absint' … … 183 183 $ppsfwoo_resubscribe_landing_page_id, 184 184 $ppsfwoo_discount_apply_to_trial, 185 $ppsfwoo_discount_waive_setup_fee,186 185 $ppsfwoo_discount, 187 186 $template_dir, … … 258 257 259 258 add_action('ppsfwoo_after_options_page', [$this, 'after_options_page']); 259 260 add_action('woocommerce_order_item_meta_end', [$this, 'update_receipt_line_item_totals'], 10, 3 ); 260 261 } 261 262 … … 268 269 add_filter('wp_new_user_notification_email', [$this, 'new_user_notification_email'], 10, 4); 269 270 270 add_filter('woocommerce_get_order_item_totals', [$this, 'update_receipt_display'], 10, 2); 271 271 add_filter('woocommerce_get_order_item_totals', [$this, 'update_receipt_subtotal'], 10, 2); 272 273 add_filter('woocommerce_email_recipient_customer_processing_order', [$this, 'suppress_processing_order_email'], 10, 2 ); 274 } 275 276 public function suppress_processing_order_email($recipient, $order) 277 { 278 if(Order::has_subscription($order)) { 279 280 return ''; 281 282 } 283 284 return $recipient; 285 } 286 287 public function update_receipt_line_item_totals($item_id, $item, $order) 288 { 289 if(!Order::has_subscription($order)) { 290 291 return; 292 293 } 294 295 $meta = $item->get_meta('exclude_from_order_total')['value'] ?? ''; 296 297 $exclude_from_order_total = $meta === 'yes'; 298 299 if($exclude_from_order_total) { 300 301 $item->set_subtotal($item->get_total()); 302 303 } 272 304 } 273 305 … … 283 315 } 284 316 285 public function update_receipt_ display($totals, $order)317 public function update_receipt_subtotal($totals, $order) 286 318 { 287 319 if(!Order::has_subscription($order)) { … … 348 380 self::clear_option_cache($option_name); 349 381 350 if( 351 'ppsfwoo_hide_inactive_plans' === $option_name && 352 false === get_transient('ppsfwoo_refresh_plans_ran') 353 ) { 354 355 set_transient('ppsfwoo_refresh_plans_ran', true, 10); 382 if('ppsfwoo_hide_inactive_plans' === $option_name) { 356 383 357 384 AjaxActionsPriv::refresh_plans(); -
subscriptions-for-woo/trunk/js/main.js
r3126531 r3251915 34 34 ppsfwooDoAjax('refresh_plans', function(r) { 35 35 var response = JSON.parse(r); 36 if(0 === response. plans.length) {36 if(0 === response.length) { 37 37 ppsfwooShowMsg("No plans found.", "warning"); 38 38 } else if(response.success) { 39 39 ppsfwooShowMsg("Successfully refreshed plans."); 40 40 ppsfwooRefreshPage(); 41 } else if(response.error) { 42 ppsfwooShowMsg(response.error, "error"); 41 43 } else { 42 44 ppsfwooShowMsg(settingsError, "error"); -
subscriptions-for-woo/trunk/js/main.min.js
r3126531 r3251915 1 jQuery(document).ready(function(n){var a,t="There has been an error. Please try again and check your <a href='"+ppsfwoo_ajax_var.settings_url+"'>WooCommerce PayPal Payments settings</a>.";function i(e="",t="success"){n("#wpcontent").prepend(`<div style="z-index: 9999; position: fixed; width: 82%" class="notice notice-${t} is-dismissible single-cached"><p>${e}</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>`),setTimeout(function(){n(".notice-dismiss").parent().fadeOut("slow",function(){n(this).remove()})},5e3),n(".notice-dismiss").click(function(e){n(this).parent().remove()})}function s(e,t,a={}){e={action:"ppsfwoo_admin_ajax_callback",method:e};n.isEmptyObject(a)||(e=n.extend({},e,a)),n.ajax({type:"POST",url:"/wp-admin/admin-ajax.php",data:e,success:t})}function o(e="tab-plans"){var t=r(window.location.href);window.location.href=t+"&tab="+e}function r(e){var t,a=e.split("?");return 2<=a.length?(t=a[1].split("&").filter(function(e){return!e.startsWith("subs_page_num=")&&!e.startsWith("tab=")}),a[0]+"?"+t.join("&")):e}function c(e){var t=document.createElement("div"),a=(t.setAttribute("role","overlay"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(0, 0, 0, 0.5)",t.style.zIndex="1000",document.createElement("div"));a.style.position="absolute",a.style.top="50%",a.style.left="50%",a.style.transform="translate(-50%, -50%)",a.style.backgroundColor="white",a.style.padding="20px",a.style.borderRadius="5px",a.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.3)",a.textContent=e||"Please wait...",t.appendChild(a),document.body.appendChild(t)}function l(){var e=document.querySelector('div[role="overlay"]');e&&e.parentNode.removeChild(e)}n("a.deactivate, a.activate").click(function(e){e.preventDefault(),c("Processing...");var e=n(this).data("plan-id"),t=n(this).data("nonce");s("modify_plan",function(e){e=JSON.parse(e);(e.error?(alert(e.error),l):o)()},{plan_id:e,paypal_action:n(this).attr("class"),nonce:t})}),n(".plan-row").on("click",".copy-button",function(e){var t=n(this).prev(".copy-text"),a=n("<textarea>");a.val(t.text()),n("body").append(a),a.select(),a[0].setSelectionRange(0,99999),document.execCommand("copy"),a.remove(),alert("Copied to clipboard: "+t.text()),e.preventDefault()}),l(),n("#subs-search").on("submit",function(e){e.preventDefault(),s("search_subscribers",function(e){e=JSON.parse(e);e.error?i(e.error,"warning"):(n("#tab-subscribers .pagination, .button.export-table-data").hide(),n("#reset").show(),n("#subscribers").replaceWith(e.html))},{email:n("#email-input").val(),search_by_email:n("#search_by_email").val()})}),n("#refresh").click(function(e){e.preventDefault(),c("Processing..."),s("refresh_plans",function(e){e=JSON.parse(e);0===e.plans.length?i("No plans found.","warning"):e.success?(i("Successfully refreshed plans."),o()):i(t,"error"),l()})}),n(".nav-tab-wrapper a").click(function(e){e.preventDefault(),n(".nav-tab").removeClass("nav-tab-active"),n(this).addClass("nav-tab-active"),n(".tab-content").hide(),a=n(this).attr("href"),n("#"+a).show()}),(n(".nav-tab-wrapper a").hasClass("nav-tab-active")?n(".nav-tab-wrapper a.nav-tab-active"):n(".nav-tab-wrapper a:first-child")).click(),n("#ppsfwoo_options").submit(function(e){var t=r(($element=n(this).find("input[name=_wp_http_referer]")).attr("value"));$element.attr("value",t+"&tab="+a)}),n("input[name=ppsfwoo_delete_plugin_data]").click(function(e){if(n(this).is(":checked"))return confirm("Selecting this option will delete plugin options and the subscribers table on plugin deactivation. Are you sure you want to do this?\n\nThe setting will take effect after you 'Save Changes' below.")})});1 jQuery(document).ready(function(n){var a,t="There has been an error. Please try again and check your <a href='"+ppsfwoo_ajax_var.settings_url+"'>WooCommerce PayPal Payments settings</a>.";function i(e="",t="success"){n("#wpcontent").prepend(`<div style="z-index: 9999; position: fixed; width: 82%" class="notice notice-${t} is-dismissible single-cached"><p>${e}</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>`),setTimeout(function(){n(".notice-dismiss").parent().fadeOut("slow",function(){n(this).remove()})},5e3),n(".notice-dismiss").click(function(e){n(this).parent().remove()})}function s(e,t,a={}){e={action:"ppsfwoo_admin_ajax_callback",method:e};n.isEmptyObject(a)||(e=n.extend({},e,a)),n.ajax({type:"POST",url:"/wp-admin/admin-ajax.php",data:e,success:t})}function r(e="tab-plans"){var t=o(window.location.href);window.location.href=t+"&tab="+e}function o(e){var t,a=e.split("?");return 2<=a.length?(t=a[1].split("&").filter(function(e){return!e.startsWith("subs_page_num=")&&!e.startsWith("tab=")}),a[0]+"?"+t.join("&")):e}function c(e){var t=document.createElement("div"),a=(t.setAttribute("role","overlay"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(0, 0, 0, 0.5)",t.style.zIndex="1000",document.createElement("div"));a.style.position="absolute",a.style.top="50%",a.style.left="50%",a.style.transform="translate(-50%, -50%)",a.style.backgroundColor="white",a.style.padding="20px",a.style.borderRadius="5px",a.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.3)",a.textContent=e||"Please wait...",t.appendChild(a),document.body.appendChild(t)}function l(){var e=document.querySelector('div[role="overlay"]');e&&e.parentNode.removeChild(e)}n("a.deactivate, a.activate").click(function(e){e.preventDefault(),c("Processing...");var e=n(this).data("plan-id"),t=n(this).data("nonce");s("modify_plan",function(e){e=JSON.parse(e);(e.error?(alert(e.error),l):r)()},{plan_id:e,paypal_action:n(this).attr("class"),nonce:t})}),n(".plan-row").on("click",".copy-button",function(e){var t=n(this).prev(".copy-text"),a=n("<textarea>");a.val(t.text()),n("body").append(a),a.select(),a[0].setSelectionRange(0,99999),document.execCommand("copy"),a.remove(),alert("Copied to clipboard: "+t.text()),e.preventDefault()}),l(),n("#subs-search").on("submit",function(e){e.preventDefault(),s("search_subscribers",function(e){e=JSON.parse(e);e.error?i(e.error,"warning"):(n("#tab-subscribers .pagination, .button.export-table-data").hide(),n("#reset").show(),n("#subscribers").replaceWith(e.html))},{email:n("#email-input").val(),search_by_email:n("#search_by_email").val()})}),n("#refresh").click(function(e){e.preventDefault(),c("Processing..."),s("refresh_plans",function(e){e=JSON.parse(e);0===e.length?i("No plans found.","warning"):e.success?(i("Successfully refreshed plans."),r()):e.error?i(e.error,"error"):i(t,"error"),l()})}),n(".nav-tab-wrapper a").click(function(e){e.preventDefault(),n(".nav-tab").removeClass("nav-tab-active"),n(this).addClass("nav-tab-active"),n(".tab-content").hide(),a=n(this).attr("href"),n("#"+a).show()}),(n(".nav-tab-wrapper a").hasClass("nav-tab-active")?n(".nav-tab-wrapper a.nav-tab-active"):n(".nav-tab-wrapper a:first-child")).click(),n("#ppsfwoo_options").submit(function(e){var t=o(($element=n(this).find("input[name=_wp_http_referer]")).attr("value"));$element.attr("value",t+"&tab="+a)}),n("input[name=ppsfwoo_delete_plugin_data]").click(function(e){if(n(this).is(":checked"))return confirm("Selecting this option will delete plugin options and the subscribers table on plugin deactivation. Are you sure you want to do this?\n\nThe setting will take effect after you 'Save Changes' below.")})}); -
subscriptions-for-woo/trunk/readme.txt
r3251356 r3251915 4 4 License: GPLv2 or later 5 5 License URI: http://www.gnu.org/licenses/gpl-2.0.html 6 Stable tag: 2.4. 66 Stable tag: 2.4.7 7 7 WC tested up to: 9.7.1 8 8 Requires at least: 6.4.3 … … 106 106 == Changelog == 107 107 108 = 2.4.7 = 109 * Feature: add subscription start time to order details 110 * Bugfix: plans not updating in gui on plugin activation when using redis cache 111 * Bugfix: plugin reactivation causes database error on upgrade 112 * Improvement: increase timeout for wp_remote_request 113 * Improvement: isset check for plan_id and product_id in ajax actions 114 * Improvement: change Order set_taxes method from private to public static 115 108 116 = 2.4.6 = 109 117 * Feature: Allow applying different tax rates to woocommerce order based on paypal plan definition -
subscriptions-for-woo/trunk/subscriptions-for-woo.php
r3251356 r3251915 8 8 * License: GPLv2 or later 9 9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 * Version: 2.4. 610 * Version: 2.4.7 11 11 * WC requires at least: 8.6.0 12 12 * WC tested up to: 9.7.1
Note: See TracChangeset
for help on using the changeset viewer.