Changeset 3411483
- Timestamp:
- 12/04/2025 10:29:22 PM (3 months ago)
- Location:
- dl-order-boost/trunk
- Files:
-
- 3 edited
-
changelog.txt (modified) (1 diff)
-
dl-order-boost.php (modified) (6 diffs)
-
readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dl-order-boost/trunk/changelog.txt
r3410783 r3411483 1 1 *** Order Boost — First & Second Order Discounts *** 2 3 2025-12-04 - version 1.0.1 4 * Improved discount eligibility detection for guest customers. 5 * Discount now applies automatically after email entry on checkout (no page reload needed). 6 * Ensures accurate first-order validation when using the classic checkout AJAX flow. 7 * Minor code cleanup and improved compatibility with dynamic checkout updates. 2 8 3 9 2025-12-03 - version 1.0.0 -
dl-order-boost/trunk/dl-order-boost.php
r3410783 r3411483 3 3 * Plugin Name: Order Boost — First & Second Order Discounts 4 4 * Description: Reward first-time buyers with automatic discounts — and upgrade to Pro for second-order rewards. Simple, fast WooCommerce conversion boost. 5 * Version: 1.0. 05 * Version: 1.0.1 6 6 * Requires at least: 6.0 7 7 * Requires PHP: 7.4 … … 204 204 <select name="<?php echo esc_attr(self::OPTION_KEY); ?>[discount_type]"> 205 205 <option value="percent" <?php selected($opts['discount_type'], 'percent'); ?>> 206 <?php esc_html_e('Percentage', 'dl-order-boost'); ?></option> 206 <?php esc_html_e('Percentage', 'dl-order-boost'); ?> 207 </option> 207 208 <option value="fixed" <?php selected($opts['discount_type'], 'fixed'); ?>> 208 <?php esc_html_e('Fixed amount', 'dl-order-boost'); ?></option> 209 <?php esc_html_e('Fixed amount', 'dl-order-boost'); ?> 210 </option> 209 211 </select> 210 212 <p class="description"> … … 243 245 value="<?php echo esc_attr($opts['min_subtotal']); ?>" /> 244 246 <p class="description"> 245 <?php esc_html_e('Cart subtotal before tax; shipping ignored.', 'dl-order-boost'); ?></p> 247 <?php esc_html_e('Cart subtotal before tax; shipping ignored.', 'dl-order-boost'); ?> 248 </p> 246 249 </td> 247 250 </tr> … … 290 293 } 291 294 292 // Allow classic pages + Store API (Blocks) 295 // Detect classic checkout AJAX updates (?wc-ajax=update_order_review). 296 $is_checkout_ajax = ( 297 defined('DOING_AJAX') 298 && DOING_AJAX 299 && isset($_REQUEST['wc-ajax']) 300 && 'update_order_review' === sanitize_text_field(wp_unslash($_REQUEST['wc-ajax'])) 301 ); 302 303 // Detect Store API (Blocks). 304 $is_store_api = (defined('REST_REQUEST') && REST_REQUEST); 305 306 307 // Allow: 308 // - Cart page 309 // - Checkout page 310 // - Store API (Blocks) 311 // - Classic checkout AJAX 293 312 if ( 294 313 !is_cart() 295 314 && !is_checkout() 296 && !(defined('REST_REQUEST') && REST_REQUEST) 315 && !$is_store_api 316 && !$is_checkout_ajax 297 317 ) { 298 318 return; … … 310 330 } 311 331 312 // Confirm settings nonce when saving settings (defen se in depth)332 // Confirm settings nonce when saving settings (defence in depth) 313 333 if (is_admin() && isset($_POST[self::NONCE_KEY])) { 314 315 334 $nonce = sanitize_text_field(wp_unslash($_POST[self::NONCE_KEY])); 316 317 335 if (!wp_verify_nonce($nonce, self::NONCE_KEY)) { 318 336 return; … … 326 344 327 345 if ($user_id > 0) { 346 // Logged in – we'll use their previous orders by user ID. 328 347 } else { 348 // 1) Try WooCommerce customer object (works in many flows). 329 349 if (function_exists('WC') && WC()->customer) { 330 350 $email = WC()->customer->get_billing_email(); 331 351 } 332 352 353 // 2) Classic checkout POST (non-blocks). 333 354 if (!$email && isset($_POST['billing_email'])) { 334 355 $email = sanitize_email(wp_unslash($_POST['billing_email'])); 335 356 } 336 357 358 // 3) Store API (Blocks checkout) — pull from current REST request. 359 if (!$email && $is_store_api && class_exists('\Automattic\WooCommerce\StoreApi\Utilities\SaleUtils')) { 360 $utils = \Automattic\WooCommerce\StoreApi\Utilities\SaleUtils::get_instance(); 361 $request = ($utils && method_exists($utils, 'get_request')) ? $utils->get_request() : null; 362 363 if ($request instanceof \WP_REST_Request) { 364 $billing = $request->get_param('billing_address'); 365 if (is_array($billing) && !empty($billing['email'])) { 366 $email = sanitize_email((string) $billing['email']); 367 } 368 } 369 } 370 337 371 if (!$email) { 372 // Still no idea who this is – can't know if it's their first order. 338 373 return; 339 374 } -
dl-order-boost/trunk/readme.txt
r3410783 r3411483 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPL-3.0-or-later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 27 27 - Predictable totals, minimal conflicts with coupon logic, and clearer reporting. Need a real coupon? You can filter the label or adapt to an auto-applied coupon if preferred. 28 28 29 **💡 Note:** 30 - In the block-based checkout, WooCommerce only recalculates totals once enough billing details are entered to validate the customer. Typing an email alone will not immediately update prices — but any eligible discount is always applied automatically before the order is completed. 31 29 32 == Pro Version == 30 33 … … 41 44 **Get Pro** 42 45 Purchase a licence here: 43 👉 https://checkout.freemius.com/plugin/21931/plan/36625/ 46 [👉 Buy an Order Boost Pro licence](https://checkout.freemius.com/plugin/21931/plan/36625/) 44 47 45 48 == Installation == … … 57 60 = Which order statuses count as previous orders? = 58 61 `processing`, `completed`, and `on-hold`. You can adjust by editing the status list in the code. 62 63 = Does the discount appear as soon as a guest types their email in the block checkout? = 64 Discount eligibility for guest customers is checked as part of WooCommerce's checkout totals calculation. Simply entering an email address does not trigger totals to update in the block-based checkout. WooCommerce recalculates totals automatically once the customer completes their billing details 65 (for example, after address fields are filled or when using autofill). At that point, any eligible 66 first-order discount will appear. The discount will always be applied before the order is placed 67 if the customer is eligible. 59 68 60 69 = Does this plugin create a coupon code? = … … 78 87 == Changelog == 79 88 89 = 1.0.1 — 2025-12-04 = 90 * Improved discount eligibility detection for guest customers. 91 * Discount now applies automatically after email entry on checkout (no page reload needed). 92 * Ensures accurate first-order validation when using the classic checkout AJAX flow. 93 * Minor code cleanup and improved compatibility with dynamic checkout updates. 94 80 95 = 1.0.0 — 2025-12-03 = 81 96 * Initial release. … … 83 98 == Upgrade Notice == 84 99 85 = 1.0. 0=86 I nitial release with new-customer detection, threshold, and percent/fixed discount types.100 = 1.0.1 = 101 Improves discount detection for guest customers — now automatically applies first-order discounts as soon as a valid email is entered at checkout. 87 102 88 103 == Uninstall ==
Note: See TracChangeset
for help on using the changeset viewer.