Plugin Directory

Changeset 3490473


Ignore:
Timestamp:
03/25/2026 04:02:14 AM (3 days ago)
Author:
addonsorg
Message:

Release new version

Location:
yeediscounts
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • yeediscounts/tags/1.0.5/backend/rules.php

    r3478717 r3490473  
    221221     * Match all conditions (AND logic)
    222222     */
    223     protected static function match_conditions(array $conditions): bool
     223    public static function match_conditions(array $conditions): bool
    224224    {
    225225        foreach ($conditions as $cond) {
     
    233233     * Match a single condition
    234234     */
    235     protected static function match_condition(array $cond): bool
     235    public static function match_condition(array $cond): bool
    236236    {
    237237        $type = $cond['type'] ?? '';
  • yeediscounts/tags/1.0.5/frontend/discount_bar.php

    r3478717 r3490473  
    11<?php
    2 if (! defined('ABSPATH')) {
     2if (!defined('ABSPATH')) {
    33    exit; // Exit if accessed directly
    44}
     
    4848        $is_cart_checkout = is_cart() || is_checkout();
    4949
    50         if (! $is_product_page && ! $is_cart_checkout) {
     50        if (!$is_product_page && !$is_cart_checkout) {
    5151            return;
    5252        }
     
    127127            // Re-use existing filter check for Product Page context relevance
    128128            $cart_item = [
    129                 'product_id'   => $product->get_id(),
     129                'product_id' => $product->get_id(),
    130130                'variation_id' => 0,
    131                 'data'         => $product,
    132                 'quantity'     => 1
     131                'data' => $product,
     132                'quantity' => 1
    133133            ];
    134134
     
    140140                printf(
    141141                    '<div class="yeekit-discount-bar %4$s" style="--yk-bar-bg: %1$s; --yk-bar-text: %2$s;">
    142                         <span class="yeekit-bar-icon">%5$s</span>
    143142                        <span class="yeekit-bar-message">%3$s</span>
    144143                    </div>',
    145144                    esc_attr($bg_color),
    146145                    esc_attr($text_color),
    147                     wp_kses_post($message),
    148                     $is_progress ? 'yeekit-bar-progress' : 'yeekit-bar-success',
    149                     $is_progress ? '&#9888;' : '&#10003;' // Warning icon vs Checkmark
     146                    wp_kses_post($message)
    150147                );
    151148            }
  • yeediscounts/tags/1.0.5/frontend/filter.php

    r3478717 r3490473  
    11<?php
    2 if (! defined('ABSPATH')) exit; // Exit if accessed directly
     2if (!defined('ABSPATH'))
     3    exit; // Exit if accessed directly
    34
    45class Yeekit_Dynamic_Discounts_Filter
     
    3536            switch ($type) {
    3637                case 'cart_item_products':
    37                     $check_ids = array_map('absint', (array)$value);
     38                    $check_ids = array_map('absint', (array) $value);
    3839                    if (in_array($product_id, $check_ids) || ($variation_id && in_array($variation_id, $check_ids))) {
    3940                        $match = true;
     
    5556                    // format taxonomy:term_slug
    5657                    $check_id = $variation_id ? $variation_id : $product_id;
    57                     foreach ((array)$value as $attr_str) {
     58                    foreach ((array) $value as $attr_str) {
    5859                        if (strpos($attr_str, ':') !== false) {
    5960                            [$tax, $slug] = explode(':', $attr_str, 2);
  • yeediscounts/tags/1.0.5/frontend/free_shipping.php

    r3478717 r3490473  
    11<?php
    2 if (! defined('ABSPATH')) exit; // Exit if accessed directly
     2if (!defined('ABSPATH'))
     3    exit; // Exit if accessed directly
    34
    45class Yeekit_Dynamic_Discounts_Free_Shipping
     
    1213    public function handle_shipping($rates, $package)
    1314    {
    14         if (is_admin() && ! defined('DOING_AJAX')) {
     15        if (is_admin() && !defined('DOING_AJAX')) {
    1516            return $rates;
    1617        }
     
    2526        }
    2627
    27         if (empty($fs_rules)) return $rates;
     28        if (empty($fs_rules))
     29            return $rates;
    2830
    2931        // Check if ANY rule matches
    3032        $is_valid = false;
    3133        foreach ($fs_rules as $rule) {
    32             // Validate against CART items in the package
    33             // Shipping package contains 'contents' which mimics cart
    34             // But Filter::validate_item expects cart item structure.
    35             // We can iterate package contents.
     34            // 1. Validate against global conditions (Subtotal, User Role, etc.)
     35            if (!Yeekit_Dynamic_Discounts_Rules_Manager::match_conditions($rule['conditions'] ?? [])) {
     36                continue;
     37            }
    3638
    37             // Logic: Typically Free Shipping is "If Cart meets conditions X, Y, Z".
    38             // Conditions are usually Subtotal, Quantity, or Specific Products in Cart.
    39             // Our Rules Manager Filter is Item-based? Or Cart-based?
    40             // "Yeekit_Dynamic_Discounts_Filter::validate_item" validates a SINGLE item.
    41             // BUT for Free Shipping, we usually want "Cart has Item X" effectively.
     39            // 2. Validate against CART items in the package (Product Filters)
     40            // foreach ($package['contents'] as $key => $item) {
     41            //     if (Yeekit_Dynamic_Discounts_Filter::validate_item($item, $rule)) {
     42            //         $is_valid = true;
     43            //         break;
     44            //     }
     45            // }
     46            if ($is_valid)
     47                break;
     48        }
    4249
    43             // Let's assume if ANY item in the cart satisfies the rule's conditions, Free Shipping applies?
    44             // OR do we need a special "Cart Validation" logic?
    45             // Current Filter.php supports: Subtotal (of item?), Quantity (of item?), Category, Product.
    46             // If the rule has "Subtotal greater than 100", currently it checks ITEM subtotal.
    47             // This might be a limitation for "Order Subtotal > 100".
    48             // However, usually "Filter" in this plugin context seems to select ITEMS.
    49             // If the filter selects at least one item, does the rule apply?
    50             // For now, YES. If any item matches the rule, Free Shipping is granted.
    51 
    52             foreach ($package['contents'] as $key => $item) {
    53                 if (Yeekit_Dynamic_Discounts_Filter::validate_item($item, $rule)) {
    54                     $is_valid = true;
    55                     break;
    56                 }
    57             }
    58             if ($is_valid) break;
    59         }
    6050        if ($is_valid) {
    6151            // User requested to use the Global Setting for the Title
     
    7666            $rates[$method_id] = $new_rate;
    7767        }
    78 
    7968        return $rates;
    8069    }
  • yeediscounts/trunk/backend/rules.php

    r3477700 r3490473  
    221221     * Match all conditions (AND logic)
    222222     */
    223     protected static function match_conditions(array $conditions): bool
     223    public static function match_conditions(array $conditions): bool
    224224    {
    225225        foreach ($conditions as $cond) {
     
    233233     * Match a single condition
    234234     */
    235     protected static function match_condition(array $cond): bool
     235    public static function match_condition(array $cond): bool
    236236    {
    237237        $type = $cond['type'] ?? '';
  • yeediscounts/trunk/frontend/discount_bar.php

    r3456277 r3490473  
    11<?php
    2 if (! defined('ABSPATH')) {
     2if (!defined('ABSPATH')) {
    33    exit; // Exit if accessed directly
    44}
     
    4848        $is_cart_checkout = is_cart() || is_checkout();
    4949
    50         if (! $is_product_page && ! $is_cart_checkout) {
     50        if (!$is_product_page && !$is_cart_checkout) {
    5151            return;
    5252        }
     
    127127            // Re-use existing filter check for Product Page context relevance
    128128            $cart_item = [
    129                 'product_id'   => $product->get_id(),
     129                'product_id' => $product->get_id(),
    130130                'variation_id' => 0,
    131                 'data'         => $product,
    132                 'quantity'     => 1
     131                'data' => $product,
     132                'quantity' => 1
    133133            ];
    134134
     
    140140                printf(
    141141                    '<div class="yeekit-discount-bar %4$s" style="--yk-bar-bg: %1$s; --yk-bar-text: %2$s;">
    142                         <span class="yeekit-bar-icon">%5$s</span>
    143142                        <span class="yeekit-bar-message">%3$s</span>
    144143                    </div>',
    145144                    esc_attr($bg_color),
    146145                    esc_attr($text_color),
    147                     wp_kses_post($message),
    148                     $is_progress ? 'yeekit-bar-progress' : 'yeekit-bar-success',
    149                     $is_progress ? '&#9888;' : '&#10003;' // Warning icon vs Checkmark
     146                    wp_kses_post($message)
    150147                );
    151148            }
  • yeediscounts/trunk/frontend/filter.php

    r3453635 r3490473  
    11<?php
    2 if (! defined('ABSPATH')) exit; // Exit if accessed directly
     2if (!defined('ABSPATH'))
     3    exit; // Exit if accessed directly
    34
    45class Yeekit_Dynamic_Discounts_Filter
     
    3536            switch ($type) {
    3637                case 'cart_item_products':
    37                     $check_ids = array_map('absint', (array)$value);
     38                    $check_ids = array_map('absint', (array) $value);
    3839                    if (in_array($product_id, $check_ids) || ($variation_id && in_array($variation_id, $check_ids))) {
    3940                        $match = true;
     
    5556                    // format taxonomy:term_slug
    5657                    $check_id = $variation_id ? $variation_id : $product_id;
    57                     foreach ((array)$value as $attr_str) {
     58                    foreach ((array) $value as $attr_str) {
    5859                        if (strpos($attr_str, ':') !== false) {
    5960                            [$tax, $slug] = explode(':', $attr_str, 2);
  • yeediscounts/trunk/frontend/free_shipping.php

    r3453635 r3490473  
    11<?php
    2 if (! defined('ABSPATH')) exit; // Exit if accessed directly
     2if (!defined('ABSPATH'))
     3    exit; // Exit if accessed directly
    34
    45class Yeekit_Dynamic_Discounts_Free_Shipping
     
    1213    public function handle_shipping($rates, $package)
    1314    {
    14         if (is_admin() && ! defined('DOING_AJAX')) {
     15        if (is_admin() && !defined('DOING_AJAX')) {
    1516            return $rates;
    1617        }
     
    2526        }
    2627
    27         if (empty($fs_rules)) return $rates;
     28        if (empty($fs_rules))
     29            return $rates;
    2830
    2931        // Check if ANY rule matches
    3032        $is_valid = false;
    3133        foreach ($fs_rules as $rule) {
    32             // Validate against CART items in the package
    33             // Shipping package contains 'contents' which mimics cart
    34             // But Filter::validate_item expects cart item structure.
    35             // We can iterate package contents.
     34            // 1. Validate against global conditions (Subtotal, User Role, etc.)
     35            if (!Yeekit_Dynamic_Discounts_Rules_Manager::match_conditions($rule['conditions'] ?? [])) {
     36                continue;
     37            }
    3638
    37             // Logic: Typically Free Shipping is "If Cart meets conditions X, Y, Z".
    38             // Conditions are usually Subtotal, Quantity, or Specific Products in Cart.
    39             // Our Rules Manager Filter is Item-based? Or Cart-based?
    40             // "Yeekit_Dynamic_Discounts_Filter::validate_item" validates a SINGLE item.
    41             // BUT for Free Shipping, we usually want "Cart has Item X" effectively.
     39            // 2. Validate against CART items in the package (Product Filters)
     40            // foreach ($package['contents'] as $key => $item) {
     41            //     if (Yeekit_Dynamic_Discounts_Filter::validate_item($item, $rule)) {
     42            //         $is_valid = true;
     43            //         break;
     44            //     }
     45            // }
     46            if ($is_valid)
     47                break;
     48        }
    4249
    43             // Let's assume if ANY item in the cart satisfies the rule's conditions, Free Shipping applies?
    44             // OR do we need a special "Cart Validation" logic?
    45             // Current Filter.php supports: Subtotal (of item?), Quantity (of item?), Category, Product.
    46             // If the rule has "Subtotal greater than 100", currently it checks ITEM subtotal.
    47             // This might be a limitation for "Order Subtotal > 100".
    48             // However, usually "Filter" in this plugin context seems to select ITEMS.
    49             // If the filter selects at least one item, does the rule apply?
    50             // For now, YES. If any item matches the rule, Free Shipping is granted.
    51 
    52             foreach ($package['contents'] as $key => $item) {
    53                 if (Yeekit_Dynamic_Discounts_Filter::validate_item($item, $rule)) {
    54                     $is_valid = true;
    55                     break;
    56                 }
    57             }
    58             if ($is_valid) break;
    59         }
    6050        if ($is_valid) {
    6151            // User requested to use the Global Setting for the Title
     
    7666            $rates[$method_id] = $new_rate;
    7767        }
    78 
    7968        return $rates;
    8069    }
Note: See TracChangeset for help on using the changeset viewer.