Changeset 3492415
- Timestamp:
- 03/27/2026 07:48:29 AM (30 hours ago)
- Location:
- yeediscounts
- Files:
-
- 45 added
- 6 edited
-
tags/1.0.6 (added)
-
tags/1.0.6/assets (added)
-
tags/1.0.6/assets/admin-rules.css (added)
-
tags/1.0.6/assets/admin-rules.js (added)
-
tags/1.0.6/assets/chart.js (added)
-
tags/1.0.6/assets/chart.min.js (added)
-
tags/1.0.6/assets/frontend.css (added)
-
tags/1.0.6/assets/frontend.js (added)
-
tags/1.0.6/assets/reports.js (added)
-
tags/1.0.6/backend (added)
-
tags/1.0.6/backend/blocks (added)
-
tags/1.0.6/backend/blocks/bogo.php (added)
-
tags/1.0.6/backend/blocks/bulk.php (added)
-
tags/1.0.6/backend/blocks/bxgy.php (added)
-
tags/1.0.6/backend/blocks/discount-bar.php (added)
-
tags/1.0.6/backend/blocks/discount.php (added)
-
tags/1.0.6/backend/blocks/filter.php (added)
-
tags/1.0.6/backend/blocks/general.php (added)
-
tags/1.0.6/backend/blocks/rules.php (added)
-
tags/1.0.6/backend/blocks/set.php (added)
-
tags/1.0.6/backend/import_export.php (added)
-
tags/1.0.6/backend/order_tracker.php (added)
-
tags/1.0.6/backend/orders.php (added)
-
tags/1.0.6/backend/reports.php (added)
-
tags/1.0.6/backend/rules.php (added)
-
tags/1.0.6/backend/settings.php (added)
-
tags/1.0.6/backend/table.php (added)
-
tags/1.0.6/frontend (added)
-
tags/1.0.6/frontend/bulk_discounts.php (added)
-
tags/1.0.6/frontend/bulk_table.php (added)
-
tags/1.0.6/frontend/buy_x_get_x.php (added)
-
tags/1.0.6/frontend/buy_x_get_y.php (added)
-
tags/1.0.6/frontend/bxgy_table.php (added)
-
tags/1.0.6/frontend/cart_discount.php (added)
-
tags/1.0.6/frontend/discount_bar.php (added)
-
tags/1.0.6/frontend/discounts.php (added)
-
tags/1.0.6/frontend/filter.php (added)
-
tags/1.0.6/frontend/free_shipping.php (added)
-
tags/1.0.6/frontend/price_display.php (added)
-
tags/1.0.6/frontend/sale_badge.php (added)
-
tags/1.0.6/frontend/set_discounts.php (added)
-
tags/1.0.6/frontend/set_table.php (added)
-
tags/1.0.6/frontend/simple_discount.php (added)
-
tags/1.0.6/readme.txt (added)
-
tags/1.0.6/yeediscounts.php (added)
-
trunk/assets/admin-rules.js (modified) (2 diffs)
-
trunk/backend/blocks/general.php (modified) (1 diff)
-
trunk/frontend/bulk_table.php (modified) (12 diffs)
-
trunk/frontend/discount_bar.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/yeediscounts.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yeediscounts/trunk/assets/admin-rules.js
r3454353 r3492415 458 458 const $bxgyBlock = $('.yeekit-buyx-gety-block'); 459 459 const $titleRow = $('.yeekit-discount-title-row'); 460 const $rulesBlock = $('#yeekit-dd-conditions-wrap').closest('.yeekit-dd-block'); 461 const $discountBarBlock = $('.yeekit-discount-bar-block'); 460 462 461 463 // Reset Blocks 462 464 $filterBlock.show(); 465 $rulesBlock.show(); 466 $discountBarBlock.show(); 463 467 464 468 $discountBlock.hide(); … … 475 479 } 476 480 477 if (type === 'yeekit_simple_discount' || type === 'yeekit_cart_discount' || type === 'not_selected' || !type) { 481 // If no type is selected, hide everything else 482 if (!type || type === 'not_selected') { 483 $filterBlock.hide(); 484 $rulesBlock.hide(); 485 $discountBarBlock.hide(); 486 $discountBlock.hide(); 487 return; 488 } 489 490 if (type === 'yeekit_simple_discount' || type === 'yeekit_cart_discount') { 478 491 $discountBlock.show(); 479 492 // Show title ONLY for cart discount -
yeediscounts/trunk/backend/blocks/general.php
r3454353 r3492415 59 59 <select name="rule[type]" 60 60 class="yeekit-product-discount-type yeekit-discount-type-selector"> 61 <option value=" not_selected"><?php esc_html_e('Select Discount Type', 'yeediscounts'); ?></option>61 <option value=""><?php esc_html_e('Select Discount Type', 'yeediscounts'); ?></option> 62 62 <optgroup label="<?php esc_attr_e('Simple Discount', 'yeediscounts'); ?>"> 63 63 <option value="yeekit_simple_discount" <?php selected($rule['type'] ?? '', 'yeekit_simple_discount'); ?>><?php esc_html_e('Product Adjustment', 'yeediscounts'); ?></option> -
yeediscounts/trunk/frontend/bulk_table.php
r3454353 r3492415 33 33 $rules = Yeekit_Dynamic_Discounts_Rules_Manager::get_active_rules(); 34 34 foreach ($rules as $rule) { 35 if (empty($rule['type']) || $rule['type'] !== 'yeekit_buy_x_get_x') { 35 $type = $rule['type'] ?? ''; 36 $supported_types = [ 37 'yeekit_buy_x_get_x', 38 'yeekit_buy_x_get_y', 39 'yeekit_bulk_discount', 40 'yeekit_set_discount' 41 ]; 42 if (! in_array($type, $supported_types, true)) { 36 43 continue; 37 44 } … … 43 50 'quantity' => 1 44 51 ]; 52 45 53 if (Yeekit_Dynamic_Discounts_Filter::validate_item($cart_item, $rule)) { 46 54 $matched_rule = $rule; … … 52 60 } 53 61 $tiers = []; 54 $is_bogo = ($matched_rule['type'] === 'yeekit_buy_x_get_x'); 55 if ($is_bogo) { 56 $ranges = $matched_rule['buyx_getx_adjustments']['ranges'] ?? [];; 62 $rule_type = $matched_rule['type'] ?? ''; 63 $is_bogo = ($rule_type === 'yeekit_buy_x_get_x'); 64 $is_bxgy = ($rule_type === 'yeekit_buy_x_get_y'); 65 $is_set = ($rule_type === 'yeekit_set_discount'); 66 67 if ($is_bogo || $is_bxgy || $is_set) { 68 if ($is_bogo) { 69 $ranges = $matched_rule['buyx_getx_adjustments']['ranges'] ?? []; 70 } elseif ($is_bxgy) { 71 $ranges = $matched_rule['buyx_gety_adjustments']['ranges'] ?? []; 72 } else { 73 $ranges = $matched_rule['set_adjustments']['ranges'] ?? []; 74 } 57 75 // Handle Recursive: Generate purely synthetic rows for display if recursive 58 // Assuming first valid range dictates the rule for simplicity?59 // Or merge all? BOGO usually processes sequential ranges.60 // If recursive is set on a range, we expand it.61 76 foreach ($ranges as $r) { 62 77 if (!empty($r['is_recursive'])) { 63 78 // Generate 5 steps 64 $step_min = intval($r['min_qty'] );65 $step_get = intval($r['free_qty'] );79 $step_min = intval($r['min_qty'] ?? ($r['qty'] ?? 1)); 80 $step_get = intval($r['free_qty'] ?? ($r['get_qty'] ?? 1)); 66 81 if ($step_min <= 0) $step_min = 1; 67 82 for ($i = 1; $i <= 5; $i++) { … … 71 86 'min_qty' => $qty_buy, 72 87 'max_qty' => '', // Point value 73 'type' => $r['free_type'] ?? 'free_product',74 'value' => $r['amount'] ?? 0,88 'type' => $r['free_type'] ?? ($r['discount_type'] ?? ($r['type'] ?? 'percentage')), 89 'value' => $r['amount'] ?? ($r['discount_value'] ?? ($r['value'] ?? 0)), 75 90 'get_qty' => $qty_get, 76 91 'label' => __('Tier', 'yeediscounts') . ' ' . $i, 77 'is_generated' => true 92 'is_generated' => true, 93 'get_product' => $r['get_product'] ?? [] 78 94 ]; 79 95 } 80 // Recursive implies we stop processing other ranges usually?81 // Let's break to avoid table flooding if multiple recursive ranges exist (rare)82 96 break; 83 97 } else { 84 98 // Normal Range 85 99 $tiers[] = [ 86 'min_qty' => $r['min_qty'], 87 'max_qty' => $r['max_qty'], 88 'type' => $r['free_type'] ?? 'free_product', 89 'value' => $r['amount'] ?? 0, 90 'get_qty' => $r['free_qty'] ?? 0, 91 'label' => '' 100 'min_qty' => $r['min_qty'] ?? ($r['qty'] ?? 1), 101 'max_qty' => $r['max_qty'] ?? '', 102 'type' => $r['free_type'] ?? ($r['discount_type'] ?? ($r['type'] ?? 'percentage')), 103 'value' => $r['amount'] ?? ($r['discount_value'] ?? ($r['value'] ?? 0)), 104 'get_qty' => $r['free_qty'] ?? ($r['get_qty'] ?? 0), 105 'label' => $r['label'] ?? '', 106 'get_product' => $r['get_product'] ?? [] 92 107 ]; 93 108 } … … 104 119 }); 105 120 $product_price = floatval($product->get_price()); 121 122 // Determine table title and headers 123 $table_title = $matched_rule['title'] ?? ''; 124 if (empty($table_title)) { 125 if ($is_bogo) $table_title = __('Buy X Get X', 'yeediscounts'); 126 elseif ($is_bxgy) $table_title = __('Buy X Get Y', 'yeediscounts'); 127 elseif ($is_set) $table_title = __('Bundle Discount', 'yeediscounts'); 128 else $table_title = __('Bulk Discount', 'yeediscounts'); 129 } 130 131 $range_header = __('Range', 'yeediscounts'); 132 if ($is_bogo || $is_bxgy) $range_header = __('Buy Quantity', 'yeediscounts'); 133 elseif ($is_set) $range_header = __('Set Quantity', 'yeediscounts'); 134 135 $benefit_header = __('Discount', 'yeediscounts'); 136 if ($is_bogo || $is_bxgy) $benefit_header = __('Get Benefit', 'yeediscounts'); 106 137 ?> 107 138 <div class="yeekit-bulk-table-wrapper"> 108 <h3><?php echo esc_html($ is_bogo) ? esc_html__('Buy X Get X', 'yeediscounts') : esc_html__('Bulk Discount', 'yeediscounts'); ?></h3>139 <h3><?php echo esc_html($table_title); ?></h3> 109 140 <table id="yeekit-bulk-table" class="yeekit-bulk-table-msg yeekit-table"> 110 141 <thead class="yeekit-bulk-table-thead"> … … 114 145 </th> 115 146 <th id="yeekit-bulk-table-range" class="yeekit-bulk-table-td"> 116 <span><?php echo esc_html($ is_bogo) ? esc_html__('Buy Quantity', 'yeediscounts') : esc_html__('Range', 'yeediscounts'); ?></span>147 <span><?php echo esc_html($range_header); ?></span> 117 148 </th> 118 149 <th id="yeekit-bulk-table-discount" class="yeekit-bulk-table-td"> 119 <span><?php echo esc_html($ is_bogo) ? esc_html__('Get Benefit', 'yeediscounts') : esc_html__('Discount', 'yeediscounts'); ?></span>150 <span><?php echo esc_html($benefit_header); ?></span> 120 151 </th> 121 152 </tr> … … 126 157 $max = $tier['max_qty']; 127 158 // Range display 128 if ( $is_bogo&& !empty($tier['is_generated'])) {159 if (($is_bogo || $is_bxgy || $is_set) && !empty($tier['is_generated'])) { 129 160 $range = $min; // Point value for recursive steps 130 161 } else { … … 142 173 $discount_display_text = ''; 143 174 $discounted_price_text = ''; 144 if ($is_bogo) { 145 // BOGO Info 175 $reward_desc = ''; 176 177 if ($is_bogo || $is_bxgy) { 178 // BOGO / BXGY Info 146 179 if ($type === 'free_product') { 147 180 /* translators: %s: Quantity */ … … 150 183 /* translators: 1: Quantity, 2: Percentage value */ 151 184 $discount_display_text = sprintf(__('Get %1$s at %2$s%% Off', 'yeediscounts'), $get_qty, $value); 152 } elseif ($type === 'fixed_price' ) {185 } elseif ($type === 'fixed_price' || $type === 'fixed_set_price') { 153 186 /* translators: 1: Quantity, 2: Price amount */ 154 187 $discount_display_text = sprintf(__('Get %1$s at %2$s', 'yeediscounts'), $get_qty, wc_price($value)); … … 156 189 /* translators: %s: Quantity */ 157 190 $discount_display_text = sprintf(__('Get %s (Discount)', 'yeediscounts'), $get_qty); 191 } 192 193 // BXGY Reward Description (Product/Category names) 194 if ($is_bxgy) { 195 $bxgy_adj_type = $matched_rule['buyx_gety_adjustments']['type'] ?? 'bxgy_product'; 196 $items_list = []; 197 if ($bxgy_adj_type === 'bxgy_all') { 198 $items_list[] = __('Any Product', 'yeediscounts'); 199 } elseif ($bxgy_adj_type === 'bxgy_category') { 200 $cat_ids = $tier['get_product'] ?? []; 201 foreach ((array)$cat_ids as $cid) { 202 $term = get_term($cid, 'product_cat'); 203 if ($term && !is_wp_error($term)) { 204 $items_list[] = esc_html($term->name); 205 } 206 } 207 } else { 208 $p_ids = $tier['get_product'] ?? []; 209 if (count((array)$p_ids) > 3) { 210 $items_list[] = __('Selected Products', 'yeediscounts'); 211 } else { 212 foreach ((array)$p_ids as $pid) { 213 $p = wc_get_product($pid); 214 if ($p) { 215 $items_list[] = esc_html($p->get_name()); 216 } 217 } 218 } 219 } 220 if (!empty($items_list)) { 221 $reward_desc = '(' . implode(', ', $items_list) . ')'; 222 } 223 } 224 } elseif ($is_set) { 225 // Set Discount Info 226 if ($type === 'fixed_set_price') { 227 $discount_display_text = sprintf(__('Set Price: %s', 'yeediscounts'), wc_price($value)); 228 } elseif ($type === 'percentage') { 229 $discount_display_text = $value . '% ' . __('Off', 'yeediscounts'); 230 } else { 231 $discount_display_text = wc_price($value) . ' ' . __('Off', 'yeediscounts'); 158 232 } 159 233 } else { … … 163 237 $discount_display_text = $value . '%'; 164 238 $discounted_price = $product_price * (1 - ($value / 100)); 165 } elseif ($type === 'fixed' ) {239 } elseif ($type === 'fixed' || $type === 'flat') { 166 240 $discount_display_text = wc_price($value); 167 241 $discounted_price = max(0, $product_price - $value); … … 185 259 <td class="yeekit-bulk-table-td yeekit-bulk-table-discount col_index_3" data-colindex="3"> 186 260 <span class="yeekit-table-discounted-value"><?php echo wp_kses_post($discount_display_text); ?></span> 187 <?php if (!$is_bogo && $discounted_price_text): ?> 261 <?php if ($reward_desc): ?> 262 <div class="yeekit-table-reward-desc" style="font-size: 0.85em; opacity: 0.8;"><?php echo esc_html($reward_desc); ?></div> 263 <?php endif; ?> 264 <?php if (!$is_bogo && !$is_bxgy && !$is_set && $discounted_price_text): ?> 188 265 <span class="yeekit-table-discounted-price" style="display: none"><?php echo wp_kses_post($discounted_price_text); ?></span> 189 266 <?php endif; ?> -
yeediscounts/trunk/frontend/discount_bar.php
r3490473 r3492415 139 139 140 140 printf( 141 '<div class="yeekit-discount-bar %4$s" style="--yk-bar-bg: %1$s; --yk-bar-text: %2$s;">141 '<div class="yeekit-discount-bar" style="--yk-bar-bg: %1$s; --yk-bar-text: %2$s;"> 142 142 <span class="yeekit-bar-message">%3$s</span> 143 143 </div>', -
yeediscounts/trunk/readme.txt
r3478717 r3492415 3 3 Tags: woocommerce, dynamic pricing, discounts, bulk discount 4 4 Tested up to: 6.9 5 Stable tag: 1.0. 55 Stable tag: 1.0.6 6 6 WC requires at least: 4.0 7 7 WC tested up to: 10.5 -
yeediscounts/trunk/yeediscounts.php
r3478717 r3492415 5 5 * Requires Plugins: woocommerce 6 6 * Description: Easily create and manage dynamic pricing and discount rules for your WooCommerce store. 7 * Version: 1.0. 57 * Version: 1.0.6 8 8 * Author: add-ons.org 9 9 * Author URI: https://add-ons.org … … 31 31 include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/discount_bar.php"; 32 32 include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/bulk_table.php"; 33 include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/set_table.php";34 include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/bxgy_table.php";33 // include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/set_table.php"; 34 // include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/bxgy_table.php"; 35 35 include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/sale_badge.php"; 36 36 include YEEKIT_DYNAMIC_DISCOUNTS_WOOCOMMERCE_PATH . "frontend/price_display.php";
Note: See TracChangeset
for help on using the changeset viewer.