Changeset 3480873
- Timestamp:
- 03/12/2026 07:11:40 AM (2 weeks ago)
- Location:
- codeatoz-hide-price-for-stores
- Files:
-
- 2 added
- 6 edited
-
assets/screenshot-2.png (modified) (previous)
-
assets/screenshot-3.png (modified) (previous)
-
trunk/assets/admin.css (added)
-
trunk/assets/admin.js (added)
-
trunk/codeatoz-hide-price-for-stores.php (modified) (1 diff)
-
trunk/includes/Admin/RuleEditor.php (modified) (1 diff)
-
trunk/includes/Admin/SettingsPage.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codeatoz-hide-price-for-stores/trunk/codeatoz-hide-price-for-stores.php
r3477743 r3480873 3 3 * Plugin Name: Hide Price for WooCommerce – CodeAtoZ 4 4 * Description: Control price visibility for WooCommerce stores using flexible rules. 5 * Version: 1. 1.05 * Version: 1.2.0 6 6 * Author: CodeAtoZ 7 7 * Author URI: https://codeatoz.com -
codeatoz-hide-price-for-stores/trunk/includes/Admin/RuleEditor.php
r3463970 r3480873 40 40 ], 41 41 ]; 42 43 $pro_url = 'https://codeatoz.com/hide-price-for-stores-pro-woocommerce-price-visibility-plugin-codeatoz/'; 42 44 ?> 43 45 <div class="wrap"> 44 <h1><?php esc_html_e( 'Edit Hide Price Rule', 'codeatoz-hide-price-for-stores' ); ?></h1> 46 47 <!-- Page Header --> 48 <div class="catz-page-header"> 49 <h1 class="catz-page-header__title"> 50 <?php echo null !== $rule_index 51 ? esc_html__( 'Edit Rule', 'codeatoz-hide-price-for-stores' ) 52 : esc_html__( 'New Rule', 'codeatoz-hide-price-for-stores' ); 53 ?> 54 </h1> 55 <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price' ) ); ?>" 56 style="color:#646970;text-decoration:none;font-size:13px;"> 57 ← <?php esc_html_e( 'Back to Rules', 'codeatoz-hide-price-for-stores' ); ?> 58 </a> 59 </div> 45 60 46 61 <form method="post"> 47 62 <?php wp_nonce_field( 'codeatoz_hp_save_rule' ); ?> 48 63 49 <table class="form-table"> 50 51 <tr> 52 <th><?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?></th> 53 <td> 54 <input type="text" 55 name="rule[name]" 56 value="<?php echo esc_attr( $rule['name'] ); ?>" 57 class="regular-text" 58 required> 59 </td> 60 </tr> 61 62 <tr> 63 <th><?php esc_html_e( 'Enable Rule', 'codeatoz-hide-price-for-stores' ); ?></th> 64 <td> 65 <label> 66 <input type="checkbox" name="rule[enabled]" value="1" 67 <?php checked( ! empty( $rule['enabled'] ) ); ?>> 68 <?php esc_html_e( 'Active', 'codeatoz-hide-price-for-stores' ); ?> 69 </label> 70 </td> 71 </tr> 72 73 <tr> 74 <th><?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?></th> 75 <td> 76 <input type="number" 77 name="rule[priority]" 78 value="<?php echo esc_attr( $rule['priority'] ); ?>" 79 min="1"> 80 <p class="description"> 81 <?php esc_html_e( 'Lower number = higher priority', 'codeatoz-hide-price-for-stores' ); ?> 82 </p> 83 </td> 84 </tr> 85 86 <tr> 87 <th><?php esc_html_e( 'User Condition', 'codeatoz-hide-price-for-stores' ); ?></th> 88 <td> 89 <label> 90 <input type="checkbox" 91 name="rule[conditions][user][]" 92 value="guest" 93 <?php checked( in_array( 'guest', $rule['conditions']['user'], true ) ); ?>> 94 <?php esc_html_e( 'Guests', 'codeatoz-hide-price-for-stores' ); ?> 95 </label><br> 96 97 <label> 98 <input type="checkbox" 99 name="rule[conditions][user][]" 100 value="logged_in" 101 <?php checked( in_array( 'logged_in', $rule['conditions']['user'], true ) ); ?>> 102 <?php esc_html_e( 'Logged-in users', 'codeatoz-hide-price-for-stores' ); ?> 103 </label> 104 </td> 105 </tr> 106 107 <tr> 108 <th><?php esc_html_e( 'User Roles', 'codeatoz-hide-price-for-stores' ); ?></th> 109 <td> 110 <?php 111 $wp_roles = wp_roles(); 112 foreach ( $wp_roles->roles as $key => $role ) : 113 ?> 114 <label> 64 <div class="catz-editor-wrap"> 65 66 <!-- Main Column --> 67 <div class="catz-editor-main"> 68 69 <!-- General Settings --> 70 <div class="catz-section"> 71 <div class="catz-section__header"> 72 <span class="catz-section__header-icon">⚙️</span> 73 <span class="catz-section__title"><?php esc_html_e( 'General', 'codeatoz-hide-price-for-stores' ); ?></span> 74 </div> 75 <div class="catz-section__body"> 76 77 <div class="catz-field"> 78 <label class="catz-label" for="catz-rule-name"> 79 <?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?> 80 </label> 81 <input type="text" 82 id="catz-rule-name" 83 name="rule[name]" 84 value="<?php echo esc_attr( $rule['name'] ); ?>" 85 class="catz-input" 86 placeholder="<?php esc_attr_e( 'e.g. Hide prices for guests', 'codeatoz-hide-price-for-stores' ); ?>" 87 required> 88 </div> 89 90 <div class="catz-field"> 91 <label class="catz-label"><?php esc_html_e( 'Status', 'codeatoz-hide-price-for-stores' ); ?></label> 92 <label class="catz-toggle-row"> 93 <input type="checkbox" name="rule[enabled]" value="1" 94 <?php checked( ! empty( $rule['enabled'] ) ); ?>> 95 <span><?php esc_html_e( 'Rule is active', 'codeatoz-hide-price-for-stores' ); ?></span> 96 </label> 97 </div> 98 99 <div class="catz-field"> 100 <label class="catz-label" for="catz-rule-priority"> 101 <?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?> 102 </label> 103 <input type="number" 104 id="catz-rule-priority" 105 name="rule[priority]" 106 value="<?php echo esc_attr( $rule['priority'] ); ?>" 107 class="catz-input" 108 min="1"> 109 <span class="catz-desc"><?php esc_html_e( 'Lower number = higher priority. Rules with the same priority run in order.', 'codeatoz-hide-price-for-stores' ); ?></span> 110 </div> 111 112 </div> 113 </div> 114 115 <!-- Conditions --> 116 <div class="catz-section"> 117 <div class="catz-section__header"> 118 <span class="catz-section__header-icon">🎯</span> 119 <span class="catz-section__title"><?php esc_html_e( 'Conditions', 'codeatoz-hide-price-for-stores' ); ?></span> 120 </div> 121 <div class="catz-section__body"> 122 123 <!-- User Type --> 124 <div class="catz-field"> 125 <label class="catz-label"><?php esc_html_e( 'User Type', 'codeatoz-hide-price-for-stores' ); ?></label> 126 <div class="catz-check-grid"> 127 <label class="catz-check-item"> 128 <input type="checkbox" 129 name="rule[conditions][user][]" 130 value="guest" 131 <?php checked( in_array( 'guest', $rule['conditions']['user'], true ) ); ?>> 132 <span><?php esc_html_e( 'Guests', 'codeatoz-hide-price-for-stores' ); ?></span> 133 </label> 134 <label class="catz-check-item"> 135 <input type="checkbox" 136 name="rule[conditions][user][]" 137 value="logged_in" 138 <?php checked( in_array( 'logged_in', $rule['conditions']['user'], true ) ); ?>> 139 <span><?php esc_html_e( 'Logged-in users', 'codeatoz-hide-price-for-stores' ); ?></span> 140 </label> 141 </div> 142 </div> 143 144 <!-- User Roles --> 145 <div class="catz-field"> 146 <label class="catz-label"><?php esc_html_e( 'User Roles', 'codeatoz-hide-price-for-stores' ); ?></label> 147 <div class="catz-check-grid"> 148 <?php 149 $wp_roles = wp_roles(); 150 foreach ( $wp_roles->roles as $key => $role ) : 151 ?> 152 <label class="catz-check-item"> 153 <input type="checkbox" 154 name="rule[conditions][roles][]" 155 value="<?php echo esc_attr( $key ); ?>" 156 <?php checked( in_array( $key, $rule['conditions']['roles'], true ) ); ?>> 157 <span><?php echo esc_html( $role['name'] ); ?></span> 158 </label> 159 <?php endforeach; ?> 160 </div> 161 </div> 162 163 <!-- Product IDs --> 164 <div class="catz-field"> 165 <label class="catz-label" for="catz-product-ids"> 166 <?php esc_html_e( 'Product IDs', 'codeatoz-hide-price-for-stores' ); ?> 167 </label> 168 <input type="text" 169 id="catz-product-ids" 170 class="catz-input" 171 name="rule[conditions][products]" 172 value="<?php echo esc_attr( implode( ', ', $rule['conditions']['products'] ) ); ?>" 173 placeholder="e.g. 42, 87, 120"> 174 <span class="catz-desc"><?php esc_html_e( 'Comma-separated product IDs. Leave blank to apply to all products.', 'codeatoz-hide-price-for-stores' ); ?></span> 175 </div> 176 177 <!-- Product Categories --> 178 <?php 179 $terms = get_terms( [ 180 'taxonomy' => 'product_cat', 181 'hide_empty' => false, 182 ] ); 183 if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) : 184 ?> 185 <div class="catz-field"> 186 <label class="catz-label"><?php esc_html_e( 'Product Categories', 'codeatoz-hide-price-for-stores' ); ?></label> 187 <div class="catz-check-grid"> 188 <?php foreach ( $terms as $term ) : ?> 189 <label class="catz-check-item"> 190 <input type="checkbox" 191 name="rule[conditions][categories][]" 192 value="<?php echo esc_attr( $term->term_id ); ?>" 193 <?php checked( in_array( $term->term_id, $rule['conditions']['categories'], true ) ); ?>> 194 <span><?php echo esc_html( $term->name ); ?></span> 195 </label> 196 <?php endforeach; ?> 197 </div> 198 </div> 199 <?php endif; ?> 200 201 </div> 202 </div> 203 204 <!-- Actions --> 205 <div class="catz-section"> 206 <div class="catz-section__header"> 207 <span class="catz-section__header-icon">⚡</span> 208 <span class="catz-section__title"><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></span> 209 </div> 210 <div class="catz-section__body"> 211 212 <label class="catz-action-item"> 115 213 <input type="checkbox" 116 name="rule[conditions][roles][]" 117 value="<?php echo esc_attr( $key ); ?>" 118 <?php checked( in_array( $key, $rule['conditions']['roles'], true ) ); ?>> 119 <?php echo esc_html( $role['name'] ); ?> 120 </label><br> 121 <?php endforeach; ?> 122 </td> 123 </tr> 124 125 <tr> 126 <th><?php esc_html_e( 'Product IDs', 'codeatoz-hide-price-for-stores' ); ?></th> 127 <td> 128 <input type="text" 129 class="regular-text" 130 name="rule[conditions][products]" 131 value="<?php echo esc_attr( implode( ',', $rule['conditions']['products'] ) ); ?>"> 132 </td> 133 </tr> 134 135 <tr> 136 <th><?php esc_html_e( 'Product Categories', 'codeatoz-hide-price-for-stores' ); ?></th> 137 <td> 138 <?php 139 $terms = get_terms( [ 140 'taxonomy' => 'product_cat', 141 'hide_empty' => false, 142 ] ); 143 144 if ( is_wp_error( $terms ) ) { 145 $terms = []; 146 } 147 148 foreach ( $terms as $term ) : 149 ?> 150 <label> 214 name="rule[actions][hide_price]" 215 value="1" 216 <?php checked( ! empty( $rule['actions']['hide_price'] ) ); ?>> 217 <div class="catz-action-item__text"> 218 <strong><?php esc_html_e( 'Hide Price', 'codeatoz-hide-price-for-stores' ); ?></strong> 219 <small><?php esc_html_e( 'Remove the product price from display.', 'codeatoz-hide-price-for-stores' ); ?></small> 220 </div> 221 </label> 222 223 <label class="catz-action-item"> 151 224 <input type="checkbox" 152 name="rule[conditions][categories][]" 153 value="<?php echo esc_attr( $term->term_id ); ?>" 154 <?php checked( in_array( $term->term_id, $rule['conditions']['categories'], true ) ); ?>> 155 <?php echo esc_html( $term->name ); ?> 156 </label><br> 157 <?php endforeach; ?> 158 </td> 159 </tr> 160 161 <tr> 162 <th><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></th> 163 <td> 164 <label> 165 <input type="checkbox" 166 name="rule[actions][hide_price]" 167 value="1" 168 <?php checked( ! empty( $rule['actions']['hide_price'] ) ); ?>> 169 <?php esc_html_e( 'Hide price', 'codeatoz-hide-price-for-stores' ); ?> 170 </label><br><br> 171 172 <label> 173 <input type="checkbox" 174 name="rule[actions][hide_cart]" 175 value="1" 176 <?php checked( ! empty( $rule['actions']['hide_cart'] ) ); ?>> 177 <?php esc_html_e( 'Hide Add to Cart button', 'codeatoz-hide-price-for-stores' ); ?> 178 </label><br><br> 179 180 <label> 181 <?php esc_html_e( 'Replacement Text', 'codeatoz-hide-price-for-stores' ); ?><br> 182 <input type="text" 183 class="regular-text" 184 name="rule[actions][replace_text]" 185 value="<?php echo esc_attr( $rule['actions']['replace_text'] ); ?>"> 186 </label> 187 </td> 188 </tr> 189 190 </table> 191 192 <?php submit_button( 193 __( 'Save Rule', 'codeatoz-hide-price-for-stores' ), 194 'primary', 195 'codeatoz_hp_save_rule' 196 ); ?> 225 name="rule[actions][hide_cart]" 226 value="1" 227 <?php checked( ! empty( $rule['actions']['hide_cart'] ) ); ?>> 228 <div class="catz-action-item__text"> 229 <strong><?php esc_html_e( 'Hide Add to Cart Button', 'codeatoz-hide-price-for-stores' ); ?></strong> 230 <small><?php esc_html_e( 'Remove the Add to Cart button from the product.', 'codeatoz-hide-price-for-stores' ); ?></small> 231 </div> 232 </label> 233 234 <div class="catz-field" style="margin-top:14px;"> 235 <label class="catz-label" for="catz-replace-text"> 236 <?php esc_html_e( 'Replacement Text', 'codeatoz-hide-price-for-stores' ); ?> 237 </label> 238 <input type="text" 239 id="catz-replace-text" 240 class="catz-input" 241 name="rule[actions][replace_text]" 242 value="<?php echo esc_attr( $rule['actions']['replace_text'] ); ?>" 243 placeholder="<?php esc_attr_e( 'e.g. Login to see price', 'codeatoz-hide-price-for-stores' ); ?>"> 244 <span class="catz-desc"><?php esc_html_e( 'Optional text shown where the price was. Leave blank to show nothing.', 'codeatoz-hide-price-for-stores' ); ?></span> 245 </div> 246 247 </div> 248 </div> 249 250 <!-- Save Bar --> 251 <div class="catz-save-bar"> 252 <?php submit_button( 253 __( 'Save Rule', 'codeatoz-hide-price-for-stores' ), 254 'primary', 255 'codeatoz_hp_save_rule', 256 false 257 ); ?> 258 <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price' ) ); ?>" class="catz-back-link"> 259 <?php esc_html_e( 'Cancel', 'codeatoz-hide-price-for-stores' ); ?> 260 </a> 261 </div> 262 263 </div><!-- /.catz-editor-main --> 264 265 <!-- Sidebar --> 266 <div class="catz-editor-sidebar"> 267 268 <div class="catz-info-box"> 269 <div class="catz-info-box__header"><?php esc_html_e( 'How Rules Work', 'codeatoz-hide-price-for-stores' ); ?></div> 270 <div class="catz-info-box__body"> 271 <?php esc_html_e( 'A rule matches when ALL selected conditions are met. Leave a condition empty to match any.', 'codeatoz-hide-price-for-stores' ); ?> 272 <ul> 273 <li><?php esc_html_e( 'Lower priority number = runs first', 'codeatoz-hide-price-for-stores' ); ?></li> 274 <li><?php esc_html_e( 'Roles only apply to logged-in users', 'codeatoz-hide-price-for-stores' ); ?></li> 275 <li><?php esc_html_e( 'Product IDs override category rules', 'codeatoz-hide-price-for-stores' ); ?></li> 276 </ul> 277 </div> 278 </div> 279 280 <!-- Animated Pro Card --> 281 <div class="catz-pro-card"> 282 <div class="catz-pro-card__bg"> 283 284 <div class="catz-pro-card__head"> 285 <div class="catz-pro-card__headline"> 286 <span class="catz-pro-card__eyebrow"><?php esc_html_e( 'CodeAtoZ', 'codeatoz-hide-price-for-stores' ); ?></span> 287 <p class="catz-pro-card__title"><?php esc_html_e( 'Hide Price for Stores', 'codeatoz-hide-price-for-stores' ); ?></p> 288 <span class="catz-pro-card__sub"><?php esc_html_e( '30+ targeting conditions for B2B, wholesale & membership stores.', 'codeatoz-hide-price-for-stores' ); ?></span> 289 </div> 290 <span class="catz-pro-card__badge">PRO</span> 291 </div> 292 293 <div class="catz-pro-card__price-strip"> 294 <div class="catz-pro-card__price"><sup>$</sup>39</div> 295 <div class="catz-pro-card__period"> 296 <?php esc_html_e( 'one-time payment', 'codeatoz-hide-price-for-stores' ); ?><br> 297 <?php esc_html_e( 'Lifetime updates · 1 year support', 'codeatoz-hide-price-for-stores' ); ?> 298 </div> 299 <div class="catz-pro-card__guarantee"> 300 <strong>✓ <?php esc_html_e( '30-Day Guarantee', 'codeatoz-hide-price-for-stores' ); ?></strong> 301 <?php esc_html_e( 'No-questions refund', 'codeatoz-hide-price-for-stores' ); ?> 302 </div> 303 </div> 304 305 <ul class="catz-pro-card__features"> 306 <li><span class="catz-check">✓</span><?php esc_html_e( 'Schedule rules by date / time', 'codeatoz-hide-price-for-stores' ); ?></li> 307 <li><span class="catz-check">✓</span><?php esc_html_e( 'Geo-targeting by country', 'codeatoz-hide-price-for-stores' ); ?></li> 308 <li><span class="catz-check">✓</span><?php esc_html_e( 'Cart value & purchase history rules', 'codeatoz-hide-price-for-stores' ); ?></li> 309 <li><span class="catz-check">✓</span><?php esc_html_e( 'Custom HTML price replacement', 'codeatoz-hide-price-for-stores' ); ?></li> 310 <li><span class="catz-check">✓</span><?php esc_html_e( 'Redirect action (301/302)', 'codeatoz-hide-price-for-stores' ); ?></li> 311 <li><span class="catz-check">✓</span><?php esc_html_e( 'Analytics dashboard', 'codeatoz-hide-price-for-stores' ); ?></li> 312 <li><span class="catz-check">✓</span><?php esc_html_e( 'Inquiry manager + priority support', 'codeatoz-hide-price-for-stores' ); ?></li> 313 </ul> 314 315 <div class="catz-pro-card__divider"></div> 316 317 <div class="catz-pro-card__footer"> 318 <a href="<?php echo esc_url( $pro_url ); ?>" target="_blank" class="catz-pro-card__cta"> 319 <?php esc_html_e( 'Get Pro — $39 Lifetime', 'codeatoz-hide-price-for-stores' ); ?> 320 <span class="catz-pro-card__cta-arrow">→</span> 321 </a> 322 <p class="catz-pro-card__fine"><?php esc_html_e( 'Secure checkout · Stripe & PayPal', 'codeatoz-hide-price-for-stores' ); ?></p> 323 </div> 324 325 </div> 326 </div><!-- /.catz-pro-card --> 327 328 </div><!-- /.catz-editor-sidebar --> 329 330 </div><!-- /.catz-editor-wrap --> 331 197 332 </form> 198 333 </div> -
codeatoz-hide-price-for-stores/trunk/includes/Admin/SettingsPage.php
r3463970 r3480873 10 10 public static function init() { 11 11 add_action( 'admin_menu', [ __CLASS__, 'register_menu' ] ); 12 add_action( 'admin_enqueue_scripts', [ __CLASS__, 'enqueue_assets' ] ); 13 } 14 15 public static function enqueue_assets( $hook ) { 16 if ( false === strpos( $hook, 'codeatoz-hide-price' ) ) { 17 return; 18 } 19 wp_enqueue_style( 20 'codeatoz-hide-price-admin', 21 plugin_dir_url( CODEATOZ_HP_FILE ) . 'assets/admin.css', 22 [], 23 CODEATOZ_HP_VERSION 24 ); 25 wp_enqueue_script( 26 'codeatoz-hide-price-admin', 27 plugin_dir_url( CODEATOZ_HP_FILE ) . 'assets/admin.js', 28 [], 29 CODEATOZ_HP_VERSION, 30 true 31 ); 12 32 } 13 33 … … 29 49 } 30 50 31 // Safely read action parameter32 51 $action = isset( $_GET['action'] ) 33 52 ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) 34 53 : ''; 35 54 55 if ( in_array( $action, [ 'toggle', 'duplicate', 'delete' ], true ) ) { 56 self::handle_action( $action ); 57 return; 58 } 59 36 60 if ( $action === 'edit' ) { 37 61 RuleEditor::render(); … … 39 63 } 40 64 41 $rules = get_option( 'codeatoz_hp_rules', [] ); 65 $saved = isset( $_GET['saved'] ) ? sanitize_text_field( wp_unslash( $_GET['saved'] ) ) : ''; 66 $rules = get_option( 'codeatoz_hp_rules', [] ); 67 $pro_url = 'https://codeatoz.com/hide-price-for-stores-pro-woocommerce-price-visibility-plugin-codeatoz/'; 42 68 ?> 43 69 <div class="wrap"> 44 <h1> 45 <?php esc_html_e( 'CodeAtoZ – Hide Price Rules', 'codeatoz-hide-price-for-stores' ); ?> 70 71 <!-- Pro Banner --> 72 <div class="catz-pro-banner"> 73 <div class="catz-pro-banner__left"> 74 <div class="catz-pro-banner__icon">🚀</div> 75 <div class="catz-pro-banner__text"> 76 <strong><?php esc_html_e( 'Unlock Hide Price Pro', 'codeatoz-hide-price-for-stores' ); ?></strong> 77 <span><?php esc_html_e( 'More conditions, redirect rules, date scheduling & priority support.', 'codeatoz-hide-price-for-stores' ); ?></span> 78 </div> 79 </div> 80 <div class="catz-pro-banner__features"> 81 <span class="catz-pro-banner__pill"> 82 <svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1l2.2 4.4L15 6.3l-3.5 3.4.8 4.8L8 12.1 3.7 14.5l.8-4.8L1 6.3l4.8-.9z"/></svg> 83 <?php esc_html_e( 'Date Scheduling', 'codeatoz-hide-price-for-stores' ); ?> 84 </span> 85 <span class="catz-pro-banner__pill"> 86 <svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1l2.2 4.4L15 6.3l-3.5 3.4.8 4.8L8 12.1 3.7 14.5l.8-4.8L1 6.3l4.8-.9z"/></svg> 87 <?php esc_html_e( 'Redirect Rules', 'codeatoz-hide-price-for-stores' ); ?> 88 </span> 89 <span class="catz-pro-banner__pill"> 90 <svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1l2.2 4.4L15 6.3l-3.5 3.4.8 4.8L8 12.1 3.7 14.5l.8-4.8L1 6.3l4.8-.9z"/></svg> 91 <?php esc_html_e( 'Priority Support', 'codeatoz-hide-price-for-stores' ); ?> 92 </span> 93 </div> 94 <a href="<?php echo esc_url( $pro_url ); ?>" target="_blank" class="catz-pro-banner__cta"> 95 <?php esc_html_e( 'Upgrade to Pro', 'codeatoz-hide-price-for-stores' ); ?> 96 <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 8h10M9 4l4 4-4 4"/></svg> 97 </a> 98 </div> 99 100 <!-- Page Header --> 101 <div class="catz-page-header"> 102 <h1 class="catz-page-header__title"> 103 <?php esc_html_e( 'Hide Price Rules', 'codeatoz-hide-price-for-stores' ); ?> 104 <span class="catz-badge">Free</span> 105 </h1> 46 106 <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price&action=edit' ) ); ?>" 47 class="page-title-action"> 107 class="catz-btn-primary"> 108 <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M8 3v10M3 8h10"/></svg> 48 109 <?php esc_html_e( 'Add Rule', 'codeatoz-hide-price-for-stores' ); ?> 49 110 </a> 50 </h1> 51 52 <?php if ( empty( $rules ) ) : ?> 53 <p><?php esc_html_e( 'No rules created yet.', 'codeatoz-hide-price-for-stores' ); ?></p> 54 <?php else : ?> 55 <table class="widefat striped"> 56 <thead> 57 <tr> 58 <th><?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?></th> 59 <th><?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?></th> 60 <th><?php esc_html_e( 'Status', 'codeatoz-hide-price-for-stores' ); ?></th> 61 <th><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></th> 62 </tr> 63 </thead> 64 <tbody> 65 <?php foreach ( $rules as $index => $rule ) : ?> 111 </div> 112 113 <!-- Flash notices --> 114 <?php if ( $saved === 'toggled' ) : ?> 115 <div class="catz-notice catz-notice--success">✓ <?php esc_html_e( 'Rule status updated.', 'codeatoz-hide-price-for-stores' ); ?></div> 116 <?php elseif ( $saved === 'duplicated' ) : ?> 117 <div class="catz-notice catz-notice--success">✓ <?php esc_html_e( 'Rule duplicated successfully.', 'codeatoz-hide-price-for-stores' ); ?></div> 118 <?php elseif ( $saved === 'deleted' ) : ?> 119 <div class="catz-notice catz-notice--warning">✓ <?php esc_html_e( 'Rule deleted.', 'codeatoz-hide-price-for-stores' ); ?></div> 120 <?php endif; ?> 121 122 <!-- Rules Table --> 123 <div class="catz-card"> 124 <?php if ( empty( $rules ) ) : ?> 125 <div class="catz-empty-state"> 126 <span class="catz-empty-state__icon">📋</span> 127 <p><?php esc_html_e( 'No rules created yet. Add your first rule to start hiding prices.', 'codeatoz-hide-price-for-stores' ); ?></p> 128 <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price&action=edit' ) ); ?>" 129 class="catz-btn-primary"> 130 <?php esc_html_e( 'Create First Rule', 'codeatoz-hide-price-for-stores' ); ?> 131 </a> 132 </div> 133 <?php else : ?> 134 <table class="catz-rules-table"> 135 <thead> 66 136 <tr> 67 <td><?php echo esc_html( $rule['name'] ?? '—' ); ?></td> 68 <td><?php echo esc_html( $rule['priority'] ?? 10 ); ?></td> 69 <td> 70 <?php 71 echo ! empty( $rule['enabled'] ) 72 ? esc_html__( 'Enabled', 'codeatoz-hide-price-for-stores' ) 73 : esc_html__( 'Disabled', 'codeatoz-hide-price-for-stores' ); 74 ?> 75 </td> 76 <td> 77 <a href="<?php echo esc_url( 78 admin_url( 79 'admin.php?page=codeatoz-hide-price&action=edit&rule=' . absint( $index ) 80 ) 81 ); ?>"> 82 <?php esc_html_e( 'Edit', 'codeatoz-hide-price-for-stores' ); ?> 83 </a> 84 </td> 137 <th><?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?></th> 138 <th><?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?></th> 139 <th><?php esc_html_e( 'Status', 'codeatoz-hide-price-for-stores' ); ?></th> 140 <th><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></th> 85 141 </tr> 86 <?php endforeach; ?> 87 </tbody> 88 </table> 89 <?php endif; ?> 142 </thead> 143 <tbody> 144 <?php foreach ( $rules as $index => $rule ) : 145 $enabled = ! empty( $rule['enabled'] ); 146 $toggle_url = wp_nonce_url( 147 admin_url( 'admin.php?page=codeatoz-hide-price&action=toggle&rule=' . absint( $index ) ), 148 'catz_toggle_' . $index 149 ); 150 $dup_url = wp_nonce_url( 151 admin_url( 'admin.php?page=codeatoz-hide-price&action=duplicate&rule=' . absint( $index ) ), 152 'catz_duplicate_' . $index 153 ); 154 $delete_url = wp_nonce_url( 155 admin_url( 'admin.php?page=codeatoz-hide-price&action=delete&rule=' . absint( $index ) ), 156 'catz_delete_' . $index 157 ); 158 ?> 159 <tr> 160 <td> 161 <span class="catz-rule-name"><?php echo esc_html( $rule['name'] ?? '—' ); ?></span> 162 </td> 163 <td> 164 <span class="catz-priority-badge"><?php echo esc_html( $rule['priority'] ?? 10 ); ?></span> 165 </td> 166 <td> 167 <a href="<?php echo esc_url( $toggle_url ); ?>" 168 class="catz-toggle-switch <?php echo $enabled ? 'catz-toggle-switch--on' : 'catz-toggle-switch--off'; ?>" 169 title="<?php echo $enabled ? esc_attr__( 'Click to disable', 'codeatoz-hide-price-for-stores' ) : esc_attr__( 'Click to enable', 'codeatoz-hide-price-for-stores' ); ?>"> 170 <span class="catz-toggle-switch__track"> 171 <span class="catz-toggle-switch__thumb"></span> 172 </span> 173 <span class="catz-toggle-switch__label"> 174 <?php echo $enabled 175 ? esc_html__( 'Enabled', 'codeatoz-hide-price-for-stores' ) 176 : esc_html__( 'Disabled', 'codeatoz-hide-price-for-stores' ); 177 ?> 178 </span> 179 </a> 180 </td> 181 <td> 182 <div class="catz-row-actions"> 183 <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price&action=edit&rule=' . absint( $index ) ) ); ?>" 184 class="catz-action-link catz-action-link--edit"> 185 <svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M11.5 2.5l2 2L5 13H3v-2L11.5 2.5z"/></svg> 186 <?php esc_html_e( 'Edit', 'codeatoz-hide-price-for-stores' ); ?> 187 </a> 188 <a href="<?php echo esc_url( $dup_url ); ?>" 189 class="catz-action-link catz-action-link--dup"> 190 <svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V3h8"/></svg> 191 <?php esc_html_e( 'Duplicate', 'codeatoz-hide-price-for-stores' ); ?> 192 </a> 193 <a href="<?php echo esc_url( $delete_url ); ?>" 194 class="catz-action-link catz-action-link--delete" 195 data-confirm="<?php esc_attr_e( 'Are you sure you want to delete this rule? This cannot be undone.', 'codeatoz-hide-price-for-stores' ); ?>"> 196 <svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 4h10M6 4V2h4v2M5 4v9h6V4"/></svg> 197 <?php esc_html_e( 'Delete', 'codeatoz-hide-price-for-stores' ); ?> 198 </a> 199 </div> 200 </td> 201 </tr> 202 <?php endforeach; ?> 203 </tbody> 204 </table> 205 <?php endif; ?> 206 </div> 207 90 208 </div> 91 209 <?php 92 210 } 211 212 // ---------------------------------------------------------------- 213 // Action handlers — toggle / duplicate / delete 214 // ---------------------------------------------------------------- 215 216 private static function handle_action( string $action ) { 217 218 if ( ! current_user_can( 'manage_woocommerce' ) ) { 219 wp_die( esc_html__( 'Sorry, you are not allowed to perform this action.', 'codeatoz-hide-price-for-stores' ) ); 220 } 221 222 $index = isset( $_GET['rule'] ) ? absint( wp_unslash( $_GET['rule'] ) ) : null; 223 224 if ( null === $index ) { 225 wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price' ) ); 226 exit; 227 } 228 229 $nonce_key = 'catz_' . $action . '_' . $index; 230 if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), $nonce_key ) ) { 231 wp_die( esc_html__( 'Security check failed.', 'codeatoz-hide-price-for-stores' ) ); 232 } 233 234 $rules = get_option( 'codeatoz_hp_rules', [] ); 235 236 if ( ! isset( $rules[ $index ] ) ) { 237 wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price' ) ); 238 exit; 239 } 240 241 switch ( $action ) { 242 243 case 'toggle': 244 $rules[ $index ]['enabled'] = empty( $rules[ $index ]['enabled'] ); 245 update_option( 'codeatoz_hp_rules', $rules ); 246 wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price&saved=toggled' ) ); 247 exit; 248 249 case 'duplicate': 250 $copy = $rules[ $index ]; 251 $copy['name'] = sprintf( 252 /* translators: %s = original rule name */ 253 __( '%s (Copy)', 'codeatoz-hide-price-for-stores' ), 254 $copy['name'] 255 ); 256 $copy['enabled'] = false; 257 $rules[] = $copy; 258 update_option( 'codeatoz_hp_rules', $rules ); 259 wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price&saved=duplicated' ) ); 260 exit; 261 262 case 'delete': 263 array_splice( $rules, $index, 1 ); 264 update_option( 'codeatoz_hp_rules', array_values( $rules ) ); 265 wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price&saved=deleted' ) ); 266 exit; 267 } 268 } 93 269 } -
codeatoz-hide-price-for-stores/trunk/readme.txt
r3477750 r3480873 1 1 === Hide Price for WooCommerce – CodeAtoZ === 2 2 Contributors: codeatoz 3 Tags: woocommerce, hide price, hide add to cart, b2b, wholesale 3 Tags: woocommerce, hide price, hide add to cart, b2b, wholesale, catalog mode, price visibility 4 4 Requires at least: 6.0 5 5 Tested up to: 6.9 … … 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 == Short Description == 11 12 Hide WooCommerce product prices and Add to Cart buttons using flexible rule-based conditions — ideal for B2B, wholesale, and catalog-mode stores. 12 13 13 14 == Description == 14 15 15 Hide price in WooCommerce stores using flexible rule-based conditions. Hide Price for WooCommerce – CodeAtoZ allows store owners to hide product prices and Add to Cart buttons based on user roles, login status, products, or categories.16 CodeAtoZ – Hide Price for Stores gives WooCommerce store owners complete control over product price visibility. 16 17 17 Whether you're running a B2B store, wholesale platform, members-only shop, or catalog-mode website, this plugin gives you complete control over WooCommerce price visibility without breaking core functionality.18 Whether you're running a B2B store, wholesale platform, members-only shop, or catalog-mode website, this plugin allows you to hide product prices and Add to Cart buttons based on flexible rule conditions — without breaking WooCommerce functionality. 18 19 19 Unlike CSS-based hiding methods, this plugin applies se cure server-side logic toremove prices across:20 Unlike CSS-based hiding methods, this plugin applies server-side logic to securely remove prices across: 20 21 21 22 • Shop pages … … 25 26 • WooCommerce Store API 26 27 27 This plugin is idealfor:28 Perfect for: 28 29 29 • B2B & wholesale WooCommercestores30 • B2B & wholesale stores 30 31 • Member-only pricing models 31 • Catalog-only WooCommerce websites32 • Catalog-only WooCommerce stores 32 33 • Quote-based businesses 33 34 • Private or restricted pricing models 34 35 35 The plugin can also be used to hide price until login for WooCommerce stores. 36 37 Lightweight. Secure. Clean integration with WooCommerce. 36 Lightweight. Secure. Clean integration. 38 37 39 38 --- … … 59 58 60 59 = Custom Replacement Text = 61 Display a custom message instead of price such as: 62 63 • "Login to view price" 64 • "Request a quote" 60 Display a custom message instead of price: 61 • "Login to view price" 62 • "Request a quote" 65 63 • "Contact us for pricing" 66 64 67 65 = Secure Server-Side Enforcement = 68 Prevents price exposure via browser inspection or frontend manipulation.66 Prevents price exposure via inspection tools. 69 67 70 68 = WooCommerce API Safe = 71 Fully compatible with WooCommerceREST API and headless setups.69 Fully compatible with REST API and headless setups. 72 70 73 71 --- … … 76 74 77 75 = Rule Name = 78 Internal reference name visible in the admin panel.76 Internal reference name visible in admin. 79 77 80 78 = Enable Rule = … … 82 80 83 81 = Priority = 84 Lower number = higher priority. 82 Lower number = higher priority. 85 83 Rules are evaluated in ascending order. 86 84 87 85 = User Condition = 88 Apply therule to guests or logged-in users.86 Apply rule to guests or logged-in users. 89 87 90 88 = User Roles = 91 Select specific WordPress roles. 89 Select specific WordPress roles. 92 90 Supports custom roles created by other plugins. 93 91 94 92 = Product IDs = 95 Comma-separated product IDs. 96 Leave empty to apply the ruleglobally.93 Comma-separated product IDs. 94 Leave empty to apply globally. 97 95 98 96 = Product Categories = 99 Select WooCommercecategories to restrict rule scope.97 Select categories to restrict rule scope. 100 98 101 99 = Hide Add to Cart Button = 102 Removes the purchase button when the rule is applied.100 Removes purchase button when enabled. 103 101 104 102 = Replacement Text = 105 Custom message shown instead of theprice.103 Custom message shown instead of price. 106 104 107 Rules are evaluated server-side during WooCommerce price rendering to ensure consistent behavior across the store.105 Rules are evaluated server-side during WooCommerce price rendering. 108 106 109 107 --- … … 111 109 == Installation == 112 110 113 1. Install the plugin from theWordPress Plugin Directory or upload manually.111 1. Install via WordPress Plugin Directory or upload manually. 114 112 2. Activate the plugin. 115 3. Navigate to **WooCommerce → Hide Price**.116 4. Create and configure yourrules.117 5. Save and test on thefrontend.113 3. Navigate to WooCommerce → Hide Price. 114 4. Create and configure rules. 115 5. Save and test on frontend. 118 116 119 117 --- … … 122 120 123 121 = Does this work with variable products? = 124 Yes. The plugin supports both simple and variable products.122 Yes. 125 123 126 124 = Does this hide prices in WooCommerce REST API? = 127 Yes. Prices are hidden in REST API responses when the rule applies.125 Yes. 128 126 129 127 = Can I create a catalog-only store? = 130 Yes. You can create a global rule that hides both price and Add to Cart button.128 Yes. Enable a global rule hiding price and Add to Cart. 131 129 132 = Does the pluginuse CSS to hide prices? =130 = Does it use CSS to hide prices? = 133 131 No. It uses secure server-side logic. 134 132 135 = Will thisslow down my store? =136 No. The plugin is lightweight and optimized for WooCommerce performance.133 = Will it slow down my store? = 134 No. It is lightweight and optimized. 137 135 138 136 --- … … 148 146 • Ensure WordPress and WooCommerce are updated 149 147 • Verify no theme conflicts 150 • Confirm you are using thelatest plugin version148 • Confirm latest plugin version 151 149 152 150 We actively maintain and improve this plugin. … … 162 160 • Rule export/import 163 161 • Enhanced UI improvements 164 • Additional compatibility improvements162 • Additional compatibility enhancements 165 163 166 User feedback helps guide development.164 User feedback helps shape development. 167 165 168 166 --- … … 177 175 178 176 --- 179 177 180 178 == Changelog == 181 182 = 1.1.0 =183 * Improved plugin name for better WordPress.org search visibility184 * Enhanced readme and SEO description185 * Documentation improvements186 179 187 180 = 1.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.