Plugin Directory

Changeset 3411483


Ignore:
Timestamp:
12/04/2025 10:29:22 PM (3 months ago)
Author:
digitallychee
Message:

Update plugin code to version 1.0.1

Location:
dl-order-boost/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • dl-order-boost/trunk/changelog.txt

    r3410783 r3411483  
    11*** Order Boost — First & Second Order Discounts ***
     2
     32025-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.
    28
    392025-12-03 - version 1.0.0
  • dl-order-boost/trunk/dl-order-boost.php

    r3410783 r3411483  
    33 * Plugin Name: Order Boost — First & Second Order Discounts
    44 * 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.0
     5 * Version: 1.0.1
    66 * Requires at least: 6.0
    77 * Requires PHP: 7.4
     
    204204                            <select name="<?php echo esc_attr(self::OPTION_KEY); ?>[discount_type]">
    205205                                <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>
    207208                                <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>
    209211                            </select>
    210212                            <p class="description">
     
    243245                                value="<?php echo esc_attr($opts['min_subtotal']); ?>" />
    244246                            <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>
    246249                        </td>
    247250                    </tr>
     
    290293        }
    291294
    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
    293312        if (
    294313            !is_cart()
    295314            && !is_checkout()
    296             && !(defined('REST_REQUEST') && REST_REQUEST)
     315            && !$is_store_api
     316            && !$is_checkout_ajax
    297317        ) {
    298318            return;
     
    310330        }
    311331
    312         // Confirm settings nonce when saving settings (defense in depth)
     332        // Confirm settings nonce when saving settings (defence in depth)
    313333        if (is_admin() && isset($_POST[self::NONCE_KEY])) {
    314 
    315334            $nonce = sanitize_text_field(wp_unslash($_POST[self::NONCE_KEY]));
    316 
    317335            if (!wp_verify_nonce($nonce, self::NONCE_KEY)) {
    318336                return;
     
    326344
    327345        if ($user_id > 0) {
     346            // Logged in – we'll use their previous orders by user ID.
    328347        } else {
     348            // 1) Try WooCommerce customer object (works in many flows).
    329349            if (function_exists('WC') && WC()->customer) {
    330350                $email = WC()->customer->get_billing_email();
    331351            }
    332352
     353            // 2) Classic checkout POST (non-blocks).
    333354            if (!$email && isset($_POST['billing_email'])) {
    334355                $email = sanitize_email(wp_unslash($_POST['billing_email']));
    335356            }
    336357
     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
    337371            if (!$email) {
     372                // Still no idea who this is – can't know if it's their first order.
    338373                return;
    339374            }
  • dl-order-boost/trunk/readme.txt

    r3410783 r3411483  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPL-3.0-or-later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2727- 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.
    2828
     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
    2932== Pro Version ==
    3033
     
    4144**Get Pro**
    4245Purchase 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/)
    4447
    4548== Installation ==
     
    5760= Which order statuses count as previous orders? =
    5861`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? =
     64Discount 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
     66first-order discount will appear. The discount will always be applied before the order is placed
     67if the customer is eligible.
    5968
    6069= Does this plugin create a coupon code? =
     
    7887== Changelog ==
    7988
     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
    8095= 1.0.0 — 2025-12-03 =
    8196* Initial release.
     
    8398== Upgrade Notice ==
    8499
    85 = 1.0.0 =
    86 Initial release with new-customer detection, threshold, and percent/fixed discount types.
     100= 1.0.1 =
     101Improves discount detection for guest customers — now automatically applies first-order discounts as soon as a valid email is entered at checkout.
    87102
    88103== Uninstall ==
Note: See TracChangeset for help on using the changeset viewer.