Changeset 3458839
- Timestamp:
- 02/11/2026 09:55:32 AM (6 weeks ago)
- Location:
- elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce
- Files:
-
- 26 edited
- 1 copied
-
tags/4.1.9 (copied) (copied from elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk)
-
tags/4.1.9/assets/js/req_script.js (modified) (1 diff)
-
tags/4.1.9/assets/js/settings.js (modified) (1 diff)
-
tags/4.1.9/elex-woocommerce-product-price-custom-text-discount.php (modified) (1 diff)
-
tags/4.1.9/includes/SettingsController.php (modified) (5 diffs)
-
tags/4.1.9/includes/class-ppct-init-handler.php (modified) (2 diffs)
-
tags/4.1.9/includes/elex-ppct-woocmmerce-variation-settings.php (modified) (4 diffs)
-
tags/4.1.9/readme.txt (modified) (3 diffs)
-
tags/4.1.9/vendor/autoload.php (modified) (1 diff)
-
tags/4.1.9/vendor/composer/ClassLoader.php (modified) (25 diffs)
-
tags/4.1.9/vendor/composer/InstalledVersions.php (modified) (6 diffs)
-
tags/4.1.9/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/4.1.9/vendor/composer/autoload_static.php (modified) (3 diffs)
-
tags/4.1.9/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/assets/js/req_script.js (modified) (1 diff)
-
trunk/assets/js/settings.js (modified) (1 diff)
-
trunk/elex-woocommerce-product-price-custom-text-discount.php (modified) (1 diff)
-
trunk/includes/SettingsController.php (modified) (5 diffs)
-
trunk/includes/class-ppct-init-handler.php (modified) (2 diffs)
-
trunk/includes/elex-ppct-woocmmerce-variation-settings.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/ClassLoader.php (modified) (25 diffs)
-
trunk/vendor/composer/InstalledVersions.php (modified) (6 diffs)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/assets/js/req_script.js
r3019704 r3458839 23 23 jQuery(function(){ 24 24 25 if (jQuery('#elex_ppct_discount_type').val() === 'no-discount') {26 jQuery('#elex_ppct_discount_amount').closest('tr').addClass('d-none');27 }28 29 25 // On change event of the discount type dropdown 30 26 jQuery('#elex_ppct_discount_type').change(function() { 31 if (jQuery(this).val() === 'no-discount') { 27 const selectedVal = jQuery(this).val(); 28 const $amountField = jQuery('#elex_ppct_discount_amount'); 29 if (selectedVal === 'no-discount') { 32 30 // If "No Discount" is selected, hide the discount value field 33 jQuery('#elex_ppct_discount_amount').closest('tr').addClass('d-none');31 $amountField.closest('tr').addClass('d-none'); 34 32 } else { 35 33 // If any other option is selected, show the discount value field 36 jQuery('#elex_ppct_discount_amount').closest('tr').removeClass('d-none'); 37 } 38 }); 34 $amountField.closest('tr').removeClass('d-none'); 35 if (selectedVal === 'percent') { 36 $amountField.attr('max', 100); 37 if ($amountField.val() > 100) { 38 $amountField.val(100); 39 } 40 } else { 41 $amountField.removeAttr('max'); 42 } 43 } 44 }).trigger('change'); 39 45 40 46 //include products filter -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/assets/js/settings.js
r3019704 r3458839 481 481 482 482 jQuery('.general_setting_save_chages').click(function(){ 483 if( jQuery('#exclude_product_enabled').prop('checked') ) {484 if(jQuery('.exclude_prod_by_cat').select2('data').length === 0 &&485 jQuery('.exclude_prod_by_name').select2('data').length === 0 &&486 jQuery('.exclude_prod_by_tag').select2('data').length === 0 ){487 alert(" Choose any options for exclude category or tag or name");483 // while percentage discount is enabled discount percentage should be between 0 to 100 484 if (jQuery('#elex_ppct_discount_type').val() === 'percent') { 485 const discount_value = jQuery('#elex_ppct_discount_amount').val(); 486 if (discount_value < 0 || discount_value > 100) { 487 alert("Enter valid discount percentage"); 488 488 return false; 489 489 } 490 491 } 492 if( jQuery('#limit_product_is_enabled').prop('checked') ) { 493 if(jQuery('.include_prod_by_cat').select2('data').length === 0 && 494 jQuery('.include_prod_by_name').select2('data').length === 0 && 495 jQuery('.include_prod_by_tag').select2('data').length === 0 ){ 496 alert("Choose any options for include category or tag or name"); 497 return false; 498 } 499 500 } 501 502 503 if( jQuery('#role_based_enabled').prop('checked') ) { 504 if(jQuery('.include_roles').select2('data').length === 0 && 505 jQuery('.exclude_roles').select2('data').length === 0 ){ 506 alert("Choose any options for user role."); 507 return false; 508 } 509 510 } 511 512 if( jQuery('#hide_add_cart_exclude').prop('checked') ) { 513 if(jQuery('.hidecart_exclude_prod_by_cat').select2('data').length === 0 && 514 jQuery('.hidecart_exclude_prod_by_name').select2('data').length === 0 && 515 jQuery('.hidecart_exclude_prod_by_tag').select2('data').length === 0 ){ 516 alert("Choose any options for exclude category or tag or name"); 517 return false; 518 } 519 520 } 521 522 490 } 523 491 }); 524 492 jQuery('.hidecart_setting_save_chages').click(function(){ -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/elex-woocommerce-product-price-custom-text-discount.php
r3383764 r3458839 4 4 Plugin URI: https://elextensions.com/plugin 5 5 Description: The plugin simplifies the task to add a text before and after the product price both globally and individually.It also allows you to apply a quick discount for your products. 6 Version: 4.1. 86 Version: 4.1.9 7 7 WC requires at least: 2.6.0 8 8 WC tested up to: 10.0.0 -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/includes/SettingsController.php
r3298807 r3458839 154 154 // to get the base price of the product. 155 155 public static function elex_ppct_base_price( $product ) { 156 remove_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 157 remove_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 158 159 remove_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 160 remove_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 161 162 $base_price = $product->get_regular_price(); 163 // for simple product price. 164 add_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 165 add_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 166 167 // for variable product each variation price. 168 add_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 169 add_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 170 171 return $base_price; 156 // remove the price filters to get the base price 157 self::remove_price_filters(); 158 159 // get the base price 160 $base_price = $product->get_regular_price(); 161 162 // add the price filters 163 self::add_price_filters(); 164 165 return $base_price; 172 166 } 173 167 … … 415 409 if ( 'amount' === $type && is_numeric( $price ) ) { 416 410 $price = ( $price - ( ( float ) $discount ) ); 411 if ( $price < 0 ) { 412 $price = 0; 413 } 417 414 } 418 415 if ( 'percent' === $type && is_numeric( $price ) ) { 419 416 $price = ( $price - ( $price * ( ( float ) $discount / 100 ) ) ); 417 if ( $price < 0 ) { 418 $price = 0; 419 } 420 420 } 421 421 return $price; … … 430 430 $product_id = $product->get_id(); 431 431 } 432 433 432 $product_info = wc_get_product( $product_id ); 433 434 // Prevent Recursion: Remove filters before querying product data 435 self::remove_price_filters(); 436 437 //fetch product data 438 $is_on_sale = $product->is_on_sale(); 439 440 // Restore filters immediately 441 self::add_price_filters(); 442 $current_hook = current_filter(); 443 444 // while applying this plugin's discount, no need to change/apply discount on regular price if product is on sale, 445 if ( strpos( $current_hook, 'regular_price' ) !== false && $is_on_sale ) { 446 return $price; 447 } 448 434 449 $custom_check_enable = 'no'; 435 450 $custom_discount_checkbox = 'no'; 436 437 451 if ( is_object( $product_info ) && method_exists( $product_info, 'get_meta' ) ) { 438 452 $custom_check_enable = $product_info->get_meta( 'elex_ppct_custom_fields_checkbox' ) ? $product_info->get_meta( 'elex_ppct_custom_fields_checkbox' ) : 'no'; 439 453 $custom_discount_checkbox = $product_info->get_meta( 'elex_ppct_custom_fields_discount_type_checkbox' ) ? $product_info->get_meta( 'elex_ppct_custom_fields_discount_type_checkbox' ) : 'no'; 440 454 } 441 442 443 $check_enable = get_option( 'elex_ppct_check_field' ); 455 $check_enable = get_option( 'elex_ppct_check_field' ); 444 456 445 457 if ( ! empty( $variation_id ) ) { … … 851 863 $new_settings['elex_ppct_check_field'] = isset( $_POST['elex_ppct_check_field'] ) ? true : false; 852 864 853 $new_settings['general']['limit_button_on_certain_products']['enabled'] = isset( $_POST['general']['limit_button_on_certain_products']['enabled'] ) ? true : false; 854 $new_settings['general']['limit_button_on_certain_products']['select_all'] = isset( $_POST['general']['limit_button_on_certain_products']['select_all'] ) ? true : false; 855 $new_settings['general']['limit_button_on_certain_products']['include_products_by_category'] = isset( $_POST['general']['limit_button_on_certain_products']['include_products_by_category'] ) ? map_deep( $_POST['general']['limit_button_on_certain_products']['include_products_by_category'], 'sanitize_text_field' ) : array(); 856 $new_settings['general']['limit_button_on_certain_products']['include_products_by_name'] = isset( $_POST['general']['limit_button_on_certain_products']['include_products_by_name'] ) ? map_deep( $_POST['general']['limit_button_on_certain_products']['include_products_by_name'], 'sanitize_text_field' ) : array(); 857 $new_settings['general']['limit_button_on_certain_products']['include_products_by_tag'] = isset( $_POST['general']['limit_button_on_certain_products']['include_products_by_tag'] ) ? map_deep( $_POST['general']['limit_button_on_certain_products']['include_products_by_tag'], 'sanitize_text_field' ) : array(); 858 859 $new_settings['general']['exclude_products']['enabled'] = isset( $_POST['general']['exclude_products']['enabled'] ) ? true : false; 860 $new_settings['general']['exclude_products']['select_all'] = isset( $_POST['general']['exclude_products']['select_all'] ) ? true : false; 861 $new_settings['general']['exclude_products']['by_category'] = isset( $_POST['general']['exclude_products']['by_category'] ) ? map_deep( $_POST['general']['exclude_products']['by_category'], 'sanitize_text_field' ) : array(); 862 $new_settings['general']['exclude_products']['by_name'] = isset( $_POST['general']['exclude_products']['by_name'] ) ? map_deep( $_POST['general']['exclude_products']['by_name'], 'sanitize_text_field' ) : array(); 863 $new_settings['general']['exclude_products']['by_tag'] = isset( $_POST['general']['exclude_products']['by_tag'] ) ? map_deep( $_POST['general']['exclude_products']['by_tag'], 'sanitize_text_field' ) : array(); 864 865 $new_settings['general']['role_based_filter']['enabled'] = isset( $_POST['general']['role_based_filter']['enabled'] ) ? true : false; 866 $new_settings['general']['role_based_filter']['include_roles'] = isset( $_POST['general']['role_based_filter']['include_roles'] ) ? map_deep( $_POST['general']['role_based_filter']['include_roles'], 'sanitize_text_field' ) : array(); 867 $new_settings['general']['role_based_filter']['exclude_roles'] = isset( $_POST['general']['role_based_filter']['exclude_roles'] ) ? map_deep( $_POST['general']['role_based_filter']['exclude_roles'], 'sanitize_text_field' ) : array(); 865 // set empty values for premium settings on basic build 866 $defaults = [ 867 'limit_button_on_certain_products' => [ 868 'enabled' => false, 869 'select_all' => false, 870 'include_products_by_category' => [], 871 'include_products_by_name' => [], 872 'include_products_by_tag' => [], 873 ], 874 'exclude_products' => [ 875 'enabled' => false, 876 'select_all' => false, 877 'by_category' => [], 878 'by_name' => [], 879 'by_tag' => [], 880 ], 881 'role_based_filter' => [ 882 'enabled' => false, 883 'include_roles' => [], 884 'exclude_roles' => [], 885 ], 886 ]; 887 888 $new_settings['general'] = $defaults; 868 889 869 890 return $general_setting_options->merge( $new_settings ); … … 879 900 880 901 } 902 /** 903 * Disables the custom discount logic. 904 * It ensures that the product returns its original database price (regular or sale) 905 * without the plugin's additional calculations being applied. 906 */ 907 public static function remove_price_filters() { 908 remove_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 909 remove_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 910 remove_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 911 remove_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 912 } 913 914 /** 915 * Enables the custom discount logic. 916 * Whenever WooCommerce asks for a product price, the 'elex_ppct_discount_product' 917 * method will intercept it and apply the configured discount. 918 */ 919 public static function add_price_filters() { 920 add_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 921 add_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 922 add_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 923 add_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 924 } 881 925 } -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/includes/class-ppct-init-handler.php
r3039228 r3458839 39 39 } 40 40 41 public function form_settings_localize_script() {42 43 wp_localize_script(44 'elex_ppct_formsetting',45 'raq_formsetting_ajax_object',46 array(47 'ajax_url' => admin_url( 'admin-ajax.php' ),48 'nonce' => wp_create_nonce( 'raq-formsetting-ajax-nonce' ),49 )50 );51 }52 53 41 public function enqueue_scripts() { 54 42 global $plugin_page; … … 56 44 $include_page = array( 'elex_product_price_custom_text_and_discount', 'ppct-help_support', 'ppct-go-premium' ); 57 45 if ( in_array( $page, $include_page ) ) { 58 59 wp_enqueue_script( 'elex_ppct_formsetting', plugins_url( dirname( $this->plugin_basename ) . '/assets/js/components/form_settings.min.js' ), array( 'jquery', 'wp-element', 'wp-i18n' ), self::VERSION );60 self::form_settings_localize_script();61 46 62 47 wp_enqueue_script( 'elex_ppct_select_2_js', plugins_url( dirname( $this->plugin_basename ) . '/assets/js/select2-min.js' ), array( 'jquery', 'underscore' ), self::VERSION, true ); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/includes/elex-ppct-woocmmerce-variation-settings.php
r3019704 r3458839 165 165 jQuery(function($){ 166 166 167 // All fields checkbox 168 const elex_ppct_custom_fields_checkbox = jQuery('#elex_ppct_custom_fields_checkbox'); 169 elex_ppct_custom_fields_checkbox.click(function(){ 170 var value=jQuery(this).is(':checked'); 171 if(value === true ){ 172 jQuery('#elex_ppct_display_fields').show(); 167 // The main "custom text and discount" enable/disable checkbox for product 168 jQuery('#elex_ppct_custom_fields_checkbox').on('change', function() { 169 jQuery('#elex_ppct_display_fields').toggle(this.checked); 170 }).change(); 171 172 // Prefix checkbox 173 jQuery('#elex_ppct_custom_fields_prefix_checkbox').on('change', function() { 174 jQuery('#elex_ppct_custom_fields_prefix').closest('p').toggle(this.checked); 175 }).change(); 176 177 // Suffix checkbox 178 jQuery('#elex_ppct_custom_fields_suffix_checkbox').on('change', function() { 179 jQuery('.elex_ppct_custom_fields_suffix_field').closest('p').toggle(this.checked); 180 }).change(); 181 182 183 // Discount type checkbox 184 jQuery('#elex_ppct_custom_fields_discount_type_checkbox').on('change', function() { 185 jQuery('#elex_ppct_discount_type').closest('p').toggle(this.checked); 186 jQuery('#elex_ppct_discount_amount').closest('p').toggle(this.checked); 187 }).change(); 188 189 // Discount type change 190 jQuery("#elex_ppct_discount_type").on('change', function() { 191 const selectedVal = jQuery(this).val(); 192 const $amountField = jQuery('#elex_ppct_discount_amount'); 193 if (selectedVal === 'percent') { 194 $amountField.attr('max', 100); 195 if ($amountField.val() > 100) { 196 $amountField.val(100); 197 } 173 198 } else { 174 jQuery('#elex_ppct_display_fields').hide();199 $amountField.removeAttr('max'); 175 200 } 176 }); 177 if (elex_ppct_custom_fields_checkbox.is(":checked")) { 178 jQuery('#elex_ppct_display_fields').show(); 179 } else { 180 jQuery('#elex_ppct_display_fields').hide(); 181 } 182 183 // Prefix checkbox 184 const elex_ppct_custom_fields_prefix_checkbox = jQuery('#elex_ppct_custom_fields_prefix_checkbox'); 185 elex_ppct_custom_fields_prefix_checkbox.on('change', function() { 186 if(this.checked) { 187 jQuery('#elex_ppct_custom_fields_prefix').closest('p').show(); 188 } else { 189 jQuery('#elex_ppct_custom_fields_prefix').closest('p').hide(); 190 } 191 }); 192 if( elex_ppct_custom_fields_prefix_checkbox.is(':checked') ) { 193 jQuery('#elex_ppct_custom_fields_prefix').closest('p').show(); 194 } else { 195 jQuery('#elex_ppct_custom_fields_prefix').closest('p').hide(); 196 } 197 198 // Suffix checkbox 199 const elex_ppct_custom_fields_suffix_checkbox = jQuery('#elex_ppct_custom_fields_suffix_checkbox'); 200 elex_ppct_custom_fields_suffix_checkbox.on('change', function() { 201 if(this.checked) { 202 jQuery('.elex_ppct_custom_fields_suffix_field ').show(); 203 } else { 204 jQuery('.elex_ppct_custom_fields_suffix_field ').hide(); 205 } 206 }); 207 if ( elex_ppct_custom_fields_suffix_checkbox.is(':checked') ) { 208 jQuery('.elex_ppct_custom_fields_suffix_field ').show(); 209 } else { 210 jQuery('.elex_ppct_custom_fields_suffix_field ').hide(); 211 } 212 213 // Discount type checkbox 214 const elex_ppct_custom_fields_discount_type_checkbox = jQuery('#elex_ppct_custom_fields_discount_type_checkbox'); 215 elex_ppct_custom_fields_discount_type_checkbox.on('change', function() { 216 if(this.checked) { 217 jQuery('#elex_ppct_discount_type').closest('p').show(); 218 jQuery('#elex_ppct_discount_amount').closest('p').show(); 219 } else { 220 jQuery('#elex_ppct_discount_type').closest('p').hide(); 221 jQuery('#elex_ppct_discount_amount').closest('p').hide(); 222 } 223 }); 224 if ( elex_ppct_custom_fields_discount_type_checkbox.is(':checked') ) { 225 jQuery('#elex_ppct_discount_type').closest('p').show(); 226 jQuery('#elex_ppct_discount_amount').closest('p').show(); 227 } else { 228 jQuery('#elex_ppct_discount_type').closest('p').hide(); 229 jQuery('#elex_ppct_discount_amount').closest('p').hide(); 230 } 201 }).change(); 202 231 203 }); 232 204 … … 373 345 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 374 346 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 375 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true) ;376 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true) ;377 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true) ;347 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true).prop('disabled', false); 348 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true).prop('disabled', false); 349 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true).prop('disabled', false); 378 350 } else { 379 351 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); … … 381 353 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 382 354 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 383 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false) ;384 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false) ;385 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false) ;355 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 356 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 357 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 386 358 } 387 359 }); … … 396 368 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 397 369 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 370 371 // in intial load if the main checkbox is not checked then disable the prefix, suffix and discount checkboxs. 372 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 373 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 374 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 398 375 } 376 399 377 400 378 // Hide and Show prefix field 401 379 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 402 if(this.checked){ 403 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 404 } else { 405 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 406 } 407 }); 408 if( jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').is(':checked') ) { 409 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 410 } else { 411 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 412 } 380 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 381 }).change(); 413 382 414 383 // Hide and Show suffix field. 415 384 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 416 if(this.checked){ 417 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 418 } else { 419 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 420 } 421 }); 422 if( jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').is(':checked') ) { 423 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 424 } else { 425 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 426 } 385 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 386 }).change(); 427 387 428 388 // Hide and Show discount field. 429 389 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 430 if(this.checked){ 431 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 432 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 390 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 391 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 392 }).change(); 393 394 395 jQuery('#elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 396 const selectedVal = jQuery(this).val(); 397 const $amountField = jQuery('#elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>'); 398 if (selectedVal === 'percent') { 399 $amountField.attr('max', 100); 400 if ($amountField.val() > 100) { 401 $amountField.val(100); 402 } 433 403 } else { 434 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 435 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 404 $amountField.removeAttr('max'); 436 405 } 437 }); 438 if ( jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').is(':checked') ) { 439 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 440 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 441 } else { 442 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 443 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 444 } 406 }).change(); 407 445 408 </script> 446 409 <?php -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/readme.txt
r3383764 r3458839 3 3 Tags: before & after text, woocommerce discounts, woocommerce dynamic pricing 4 4 Requires at least: 3.0.1 5 Tested up to: 6. 86 Stable tag: 4.1. 85 Tested up to: 6.9 6 Stable tag: 4.1.9 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 59 59 == Changelog == 60 60 61 = 4.1.9 = 62 * Made compatible with WordPress 6.9 63 * Improvement and minor bug fixes 64 61 65 = 4.1.8 = 62 66 * Made compatible with WooCommerce 10.0.0 … … 228 232 == Upgrade Notice == 229 233 234 = 4.1.9 = 235 * Made compatible with WordPress 6.9 236 * Improvement and minor bug fixes 237 230 238 = 4.1.8 = 231 239 * Made compatible with WooCommerce 10.0.0 -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/vendor/autoload.php
r3383764 r3458839 15 15 } 16 16 } 17 trigger_error( 18 $err, 19 E_USER_ERROR 20 ); 17 throw new RuntimeException($err); 21 18 } 22 19 23 20 require_once __DIR__ . '/composer/autoload_real.php'; 24 21 25 return ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a::getLoader();22 return ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2::getLoader(); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/vendor/composer/ClassLoader.php
r3189599 r3458839 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 67 * @var array[] 68 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var string|null */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var array<string, self> 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param string|null $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 160 * @param string[] $classMap Class to filename map 161 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param list<string>|string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 $paths = (array) $paths; 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param list<string>|string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 $paths = (array) $paths; 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 479 * Returns the currently registered loaders indexed by their corresponding vendor directories.480 * 481 * @return self[]478 * Returns the currently registered loaders keyed by their corresponding vendor directories. 479 * 480 * @return array<string, self> 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 557 558 /** 559 * @return void 560 */ 561 private static function initializeIncludeClosure() 562 { 563 if (self::$includeFile !== null) { 564 return; 565 } 566 567 /** 568 * Scope isolated include. 569 * 570 * Prevents access to $this/self from included files. 571 * 572 * @param string $file 573 * @return void 574 */ 575 self::$includeFile = \Closure::bind(static function($file) { 576 include $file; 577 }, null, null); 578 } 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/vendor/composer/InstalledVersions.php
r3189599 r3458839 28 28 { 29 29 /** 30 * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to 31 * @internal 32 */ 33 private static $selfDir = null; 34 35 /** 30 36 * @var mixed[]|null 31 37 * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null 32 38 */ 33 39 private static $installed; 40 41 /** 42 * @var bool 43 */ 44 private static $installedIsLocalDir; 34 45 35 46 /** … … 99 110 foreach (self::getInstalled() as $installed) { 100 111 if (isset($installed['versions'][$packageName])) { 101 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);112 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; 102 113 } 103 114 } … … 120 131 public static function satisfies(VersionParser $parser, $packageName, $constraint) 121 132 { 122 $constraint = $parser->parseConstraints( $constraint);133 $constraint = $parser->parseConstraints((string) $constraint); 123 134 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 124 135 … … 310 321 self::$installed = $data; 311 322 self::$installedByVendor = array(); 323 324 // when using reload, we disable the duplicate protection to ensure that self::$installed data is 325 // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, 326 // so we have to assume it does not, and that may result in duplicate data being returned when listing 327 // all installed packages for example 328 self::$installedIsLocalDir = false; 329 } 330 331 /** 332 * @return string 333 */ 334 private static function getSelfDir() 335 { 336 if (self::$selfDir === null) { 337 self::$selfDir = strtr(__DIR__, '\\', '/'); 338 } 339 340 return self::$selfDir; 312 341 } 313 342 … … 323 352 324 353 $installed = array(); 354 $copiedLocalDir = false; 325 355 326 356 if (self::$canGetVendors) { 357 $selfDir = self::getSelfDir(); 327 358 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { 359 $vendorDir = strtr($vendorDir, '\\', '/'); 328 360 if (isset(self::$installedByVendor[$vendorDir])) { 329 361 $installed[] = self::$installedByVendor[$vendorDir]; 330 362 } elseif (is_file($vendorDir.'/composer/installed.php')) { 331 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 332 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 333 self::$installed = $installed[count($installed) - 1]; 363 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 364 $required = require $vendorDir.'/composer/installed.php'; 365 self::$installedByVendor[$vendorDir] = $required; 366 $installed[] = $required; 367 if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { 368 self::$installed = $required; 369 self::$installedIsLocalDir = true; 334 370 } 371 } 372 if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { 373 $copiedLocalDir = true; 335 374 } 336 375 } … … 341 380 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 342 381 if (substr(__DIR__, -8, 1) !== 'C') { 343 self::$installed = require __DIR__ . '/installed.php'; 382 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 383 $required = require __DIR__ . '/installed.php'; 384 self::$installed = $required; 344 385 } else { 345 386 self::$installed = array(); 346 387 } 347 388 } 348 $installed[] = self::$installed; 389 390 if (self::$installed !== array() && !$copiedLocalDir) { 391 $installed[] = self::$installed; 392 } 349 393 350 394 return $installed; -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/vendor/composer/autoload_real.php
r3383764 r3458839 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a5 class ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/vendor/composer/autoload_static.php
r3383764 r3458839 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a7 class ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( 10 'E' => 10 'E' => 11 11 array ( 12 12 'ELEX\\PPCT\\' => 10, … … 15 15 16 16 public static $prefixDirsPsr4 = array ( 17 'ELEX\\PPCT\\' => 17 'ELEX\\PPCT\\' => 18 18 array ( 19 19 0 => __DIR__ . '/../..' . '/includes', … … 28 28 { 29 29 return \Closure::bind(function () use ($loader) { 30 $loader->prefixLengthsPsr4 = ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::$prefixLengthsPsr4;31 $loader->prefixDirsPsr4 = ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::$prefixDirsPsr4;32 $loader->classMap = ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::$classMap;30 $loader->prefixLengthsPsr4 = ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::$prefixLengthsPsr4; 31 $loader->prefixDirsPsr4 = ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::$prefixDirsPsr4; 32 $loader->classMap = ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::$classMap; 33 33 34 34 }, null, ClassLoader::class); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/tags/4.1.9/vendor/composer/installed.php
r3383764 r3458839 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => 'c bcc4feb128503adb599b9db9b878f1662b629cd',6 'reference' => 'caf2aa1024cb5a885ff23a3a42cc8e520e3e9f5e', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => 'c bcc4feb128503adb599b9db9b878f1662b629cd',16 'reference' => 'caf2aa1024cb5a885ff23a3a42cc8e520e3e9f5e', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/assets/js/req_script.js
r3019704 r3458839 23 23 jQuery(function(){ 24 24 25 if (jQuery('#elex_ppct_discount_type').val() === 'no-discount') {26 jQuery('#elex_ppct_discount_amount').closest('tr').addClass('d-none');27 }28 29 25 // On change event of the discount type dropdown 30 26 jQuery('#elex_ppct_discount_type').change(function() { 31 if (jQuery(this).val() === 'no-discount') { 27 const selectedVal = jQuery(this).val(); 28 const $amountField = jQuery('#elex_ppct_discount_amount'); 29 if (selectedVal === 'no-discount') { 32 30 // If "No Discount" is selected, hide the discount value field 33 jQuery('#elex_ppct_discount_amount').closest('tr').addClass('d-none');31 $amountField.closest('tr').addClass('d-none'); 34 32 } else { 35 33 // If any other option is selected, show the discount value field 36 jQuery('#elex_ppct_discount_amount').closest('tr').removeClass('d-none'); 37 } 38 }); 34 $amountField.closest('tr').removeClass('d-none'); 35 if (selectedVal === 'percent') { 36 $amountField.attr('max', 100); 37 if ($amountField.val() > 100) { 38 $amountField.val(100); 39 } 40 } else { 41 $amountField.removeAttr('max'); 42 } 43 } 44 }).trigger('change'); 39 45 40 46 //include products filter -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/assets/js/settings.js
r3019704 r3458839 481 481 482 482 jQuery('.general_setting_save_chages').click(function(){ 483 if( jQuery('#exclude_product_enabled').prop('checked') ) {484 if(jQuery('.exclude_prod_by_cat').select2('data').length === 0 &&485 jQuery('.exclude_prod_by_name').select2('data').length === 0 &&486 jQuery('.exclude_prod_by_tag').select2('data').length === 0 ){487 alert(" Choose any options for exclude category or tag or name");483 // while percentage discount is enabled discount percentage should be between 0 to 100 484 if (jQuery('#elex_ppct_discount_type').val() === 'percent') { 485 const discount_value = jQuery('#elex_ppct_discount_amount').val(); 486 if (discount_value < 0 || discount_value > 100) { 487 alert("Enter valid discount percentage"); 488 488 return false; 489 489 } 490 491 } 492 if( jQuery('#limit_product_is_enabled').prop('checked') ) { 493 if(jQuery('.include_prod_by_cat').select2('data').length === 0 && 494 jQuery('.include_prod_by_name').select2('data').length === 0 && 495 jQuery('.include_prod_by_tag').select2('data').length === 0 ){ 496 alert("Choose any options for include category or tag or name"); 497 return false; 498 } 499 500 } 501 502 503 if( jQuery('#role_based_enabled').prop('checked') ) { 504 if(jQuery('.include_roles').select2('data').length === 0 && 505 jQuery('.exclude_roles').select2('data').length === 0 ){ 506 alert("Choose any options for user role."); 507 return false; 508 } 509 510 } 511 512 if( jQuery('#hide_add_cart_exclude').prop('checked') ) { 513 if(jQuery('.hidecart_exclude_prod_by_cat').select2('data').length === 0 && 514 jQuery('.hidecart_exclude_prod_by_name').select2('data').length === 0 && 515 jQuery('.hidecart_exclude_prod_by_tag').select2('data').length === 0 ){ 516 alert("Choose any options for exclude category or tag or name"); 517 return false; 518 } 519 520 } 521 522 490 } 523 491 }); 524 492 jQuery('.hidecart_setting_save_chages').click(function(){ -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/elex-woocommerce-product-price-custom-text-discount.php
r3383764 r3458839 4 4 Plugin URI: https://elextensions.com/plugin 5 5 Description: The plugin simplifies the task to add a text before and after the product price both globally and individually.It also allows you to apply a quick discount for your products. 6 Version: 4.1. 86 Version: 4.1.9 7 7 WC requires at least: 2.6.0 8 8 WC tested up to: 10.0.0 -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/includes/SettingsController.php
r3298807 r3458839 154 154 // to get the base price of the product. 155 155 public static function elex_ppct_base_price( $product ) { 156 remove_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 157 remove_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 158 159 remove_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 160 remove_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 161 162 $base_price = $product->get_regular_price(); 163 // for simple product price. 164 add_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 165 add_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 166 167 // for variable product each variation price. 168 add_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 169 add_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 170 171 return $base_price; 156 // remove the price filters to get the base price 157 self::remove_price_filters(); 158 159 // get the base price 160 $base_price = $product->get_regular_price(); 161 162 // add the price filters 163 self::add_price_filters(); 164 165 return $base_price; 172 166 } 173 167 … … 415 409 if ( 'amount' === $type && is_numeric( $price ) ) { 416 410 $price = ( $price - ( ( float ) $discount ) ); 411 if ( $price < 0 ) { 412 $price = 0; 413 } 417 414 } 418 415 if ( 'percent' === $type && is_numeric( $price ) ) { 419 416 $price = ( $price - ( $price * ( ( float ) $discount / 100 ) ) ); 417 if ( $price < 0 ) { 418 $price = 0; 419 } 420 420 } 421 421 return $price; … … 430 430 $product_id = $product->get_id(); 431 431 } 432 433 432 $product_info = wc_get_product( $product_id ); 433 434 // Prevent Recursion: Remove filters before querying product data 435 self::remove_price_filters(); 436 437 //fetch product data 438 $is_on_sale = $product->is_on_sale(); 439 440 // Restore filters immediately 441 self::add_price_filters(); 442 $current_hook = current_filter(); 443 444 // while applying this plugin's discount, no need to change/apply discount on regular price if product is on sale, 445 if ( strpos( $current_hook, 'regular_price' ) !== false && $is_on_sale ) { 446 return $price; 447 } 448 434 449 $custom_check_enable = 'no'; 435 450 $custom_discount_checkbox = 'no'; 436 437 451 if ( is_object( $product_info ) && method_exists( $product_info, 'get_meta' ) ) { 438 452 $custom_check_enable = $product_info->get_meta( 'elex_ppct_custom_fields_checkbox' ) ? $product_info->get_meta( 'elex_ppct_custom_fields_checkbox' ) : 'no'; 439 453 $custom_discount_checkbox = $product_info->get_meta( 'elex_ppct_custom_fields_discount_type_checkbox' ) ? $product_info->get_meta( 'elex_ppct_custom_fields_discount_type_checkbox' ) : 'no'; 440 454 } 441 442 443 $check_enable = get_option( 'elex_ppct_check_field' ); 455 $check_enable = get_option( 'elex_ppct_check_field' ); 444 456 445 457 if ( ! empty( $variation_id ) ) { … … 851 863 $new_settings['elex_ppct_check_field'] = isset( $_POST['elex_ppct_check_field'] ) ? true : false; 852 864 853 $new_settings['general']['limit_button_on_certain_products']['enabled'] = isset( $_POST['general']['limit_button_on_certain_products']['enabled'] ) ? true : false; 854 $new_settings['general']['limit_button_on_certain_products']['select_all'] = isset( $_POST['general']['limit_button_on_certain_products']['select_all'] ) ? true : false; 855 $new_settings['general']['limit_button_on_certain_products']['include_products_by_category'] = isset( $_POST['general']['limit_button_on_certain_products']['include_products_by_category'] ) ? map_deep( $_POST['general']['limit_button_on_certain_products']['include_products_by_category'], 'sanitize_text_field' ) : array(); 856 $new_settings['general']['limit_button_on_certain_products']['include_products_by_name'] = isset( $_POST['general']['limit_button_on_certain_products']['include_products_by_name'] ) ? map_deep( $_POST['general']['limit_button_on_certain_products']['include_products_by_name'], 'sanitize_text_field' ) : array(); 857 $new_settings['general']['limit_button_on_certain_products']['include_products_by_tag'] = isset( $_POST['general']['limit_button_on_certain_products']['include_products_by_tag'] ) ? map_deep( $_POST['general']['limit_button_on_certain_products']['include_products_by_tag'], 'sanitize_text_field' ) : array(); 858 859 $new_settings['general']['exclude_products']['enabled'] = isset( $_POST['general']['exclude_products']['enabled'] ) ? true : false; 860 $new_settings['general']['exclude_products']['select_all'] = isset( $_POST['general']['exclude_products']['select_all'] ) ? true : false; 861 $new_settings['general']['exclude_products']['by_category'] = isset( $_POST['general']['exclude_products']['by_category'] ) ? map_deep( $_POST['general']['exclude_products']['by_category'], 'sanitize_text_field' ) : array(); 862 $new_settings['general']['exclude_products']['by_name'] = isset( $_POST['general']['exclude_products']['by_name'] ) ? map_deep( $_POST['general']['exclude_products']['by_name'], 'sanitize_text_field' ) : array(); 863 $new_settings['general']['exclude_products']['by_tag'] = isset( $_POST['general']['exclude_products']['by_tag'] ) ? map_deep( $_POST['general']['exclude_products']['by_tag'], 'sanitize_text_field' ) : array(); 864 865 $new_settings['general']['role_based_filter']['enabled'] = isset( $_POST['general']['role_based_filter']['enabled'] ) ? true : false; 866 $new_settings['general']['role_based_filter']['include_roles'] = isset( $_POST['general']['role_based_filter']['include_roles'] ) ? map_deep( $_POST['general']['role_based_filter']['include_roles'], 'sanitize_text_field' ) : array(); 867 $new_settings['general']['role_based_filter']['exclude_roles'] = isset( $_POST['general']['role_based_filter']['exclude_roles'] ) ? map_deep( $_POST['general']['role_based_filter']['exclude_roles'], 'sanitize_text_field' ) : array(); 865 // set empty values for premium settings on basic build 866 $defaults = [ 867 'limit_button_on_certain_products' => [ 868 'enabled' => false, 869 'select_all' => false, 870 'include_products_by_category' => [], 871 'include_products_by_name' => [], 872 'include_products_by_tag' => [], 873 ], 874 'exclude_products' => [ 875 'enabled' => false, 876 'select_all' => false, 877 'by_category' => [], 878 'by_name' => [], 879 'by_tag' => [], 880 ], 881 'role_based_filter' => [ 882 'enabled' => false, 883 'include_roles' => [], 884 'exclude_roles' => [], 885 ], 886 ]; 887 888 $new_settings['general'] = $defaults; 868 889 869 890 return $general_setting_options->merge( $new_settings ); … … 879 900 880 901 } 902 /** 903 * Disables the custom discount logic. 904 * It ensures that the product returns its original database price (regular or sale) 905 * without the plugin's additional calculations being applied. 906 */ 907 public static function remove_price_filters() { 908 remove_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 909 remove_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 910 remove_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 911 remove_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 912 } 913 914 /** 915 * Enables the custom discount logic. 916 * Whenever WooCommerce asks for a product price, the 'elex_ppct_discount_product' 917 * method will intercept it and apply the configured discount. 918 */ 919 public static function add_price_filters() { 920 add_filter( 'woocommerce_product_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 921 add_filter( 'woocommerce_product_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 922 add_filter( 'woocommerce_product_variation_get_regular_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 923 add_filter( 'woocommerce_product_variation_get_price', array( self::class, 'elex_ppct_discount_product' ), 8, 2 ); 924 } 881 925 } -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/includes/class-ppct-init-handler.php
r3039228 r3458839 39 39 } 40 40 41 public function form_settings_localize_script() {42 43 wp_localize_script(44 'elex_ppct_formsetting',45 'raq_formsetting_ajax_object',46 array(47 'ajax_url' => admin_url( 'admin-ajax.php' ),48 'nonce' => wp_create_nonce( 'raq-formsetting-ajax-nonce' ),49 )50 );51 }52 53 41 public function enqueue_scripts() { 54 42 global $plugin_page; … … 56 44 $include_page = array( 'elex_product_price_custom_text_and_discount', 'ppct-help_support', 'ppct-go-premium' ); 57 45 if ( in_array( $page, $include_page ) ) { 58 59 wp_enqueue_script( 'elex_ppct_formsetting', plugins_url( dirname( $this->plugin_basename ) . '/assets/js/components/form_settings.min.js' ), array( 'jquery', 'wp-element', 'wp-i18n' ), self::VERSION );60 self::form_settings_localize_script();61 46 62 47 wp_enqueue_script( 'elex_ppct_select_2_js', plugins_url( dirname( $this->plugin_basename ) . '/assets/js/select2-min.js' ), array( 'jquery', 'underscore' ), self::VERSION, true ); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/includes/elex-ppct-woocmmerce-variation-settings.php
r3019704 r3458839 165 165 jQuery(function($){ 166 166 167 // All fields checkbox 168 const elex_ppct_custom_fields_checkbox = jQuery('#elex_ppct_custom_fields_checkbox'); 169 elex_ppct_custom_fields_checkbox.click(function(){ 170 var value=jQuery(this).is(':checked'); 171 if(value === true ){ 172 jQuery('#elex_ppct_display_fields').show(); 167 // The main "custom text and discount" enable/disable checkbox for product 168 jQuery('#elex_ppct_custom_fields_checkbox').on('change', function() { 169 jQuery('#elex_ppct_display_fields').toggle(this.checked); 170 }).change(); 171 172 // Prefix checkbox 173 jQuery('#elex_ppct_custom_fields_prefix_checkbox').on('change', function() { 174 jQuery('#elex_ppct_custom_fields_prefix').closest('p').toggle(this.checked); 175 }).change(); 176 177 // Suffix checkbox 178 jQuery('#elex_ppct_custom_fields_suffix_checkbox').on('change', function() { 179 jQuery('.elex_ppct_custom_fields_suffix_field').closest('p').toggle(this.checked); 180 }).change(); 181 182 183 // Discount type checkbox 184 jQuery('#elex_ppct_custom_fields_discount_type_checkbox').on('change', function() { 185 jQuery('#elex_ppct_discount_type').closest('p').toggle(this.checked); 186 jQuery('#elex_ppct_discount_amount').closest('p').toggle(this.checked); 187 }).change(); 188 189 // Discount type change 190 jQuery("#elex_ppct_discount_type").on('change', function() { 191 const selectedVal = jQuery(this).val(); 192 const $amountField = jQuery('#elex_ppct_discount_amount'); 193 if (selectedVal === 'percent') { 194 $amountField.attr('max', 100); 195 if ($amountField.val() > 100) { 196 $amountField.val(100); 197 } 173 198 } else { 174 jQuery('#elex_ppct_display_fields').hide();199 $amountField.removeAttr('max'); 175 200 } 176 }); 177 if (elex_ppct_custom_fields_checkbox.is(":checked")) { 178 jQuery('#elex_ppct_display_fields').show(); 179 } else { 180 jQuery('#elex_ppct_display_fields').hide(); 181 } 182 183 // Prefix checkbox 184 const elex_ppct_custom_fields_prefix_checkbox = jQuery('#elex_ppct_custom_fields_prefix_checkbox'); 185 elex_ppct_custom_fields_prefix_checkbox.on('change', function() { 186 if(this.checked) { 187 jQuery('#elex_ppct_custom_fields_prefix').closest('p').show(); 188 } else { 189 jQuery('#elex_ppct_custom_fields_prefix').closest('p').hide(); 190 } 191 }); 192 if( elex_ppct_custom_fields_prefix_checkbox.is(':checked') ) { 193 jQuery('#elex_ppct_custom_fields_prefix').closest('p').show(); 194 } else { 195 jQuery('#elex_ppct_custom_fields_prefix').closest('p').hide(); 196 } 197 198 // Suffix checkbox 199 const elex_ppct_custom_fields_suffix_checkbox = jQuery('#elex_ppct_custom_fields_suffix_checkbox'); 200 elex_ppct_custom_fields_suffix_checkbox.on('change', function() { 201 if(this.checked) { 202 jQuery('.elex_ppct_custom_fields_suffix_field ').show(); 203 } else { 204 jQuery('.elex_ppct_custom_fields_suffix_field ').hide(); 205 } 206 }); 207 if ( elex_ppct_custom_fields_suffix_checkbox.is(':checked') ) { 208 jQuery('.elex_ppct_custom_fields_suffix_field ').show(); 209 } else { 210 jQuery('.elex_ppct_custom_fields_suffix_field ').hide(); 211 } 212 213 // Discount type checkbox 214 const elex_ppct_custom_fields_discount_type_checkbox = jQuery('#elex_ppct_custom_fields_discount_type_checkbox'); 215 elex_ppct_custom_fields_discount_type_checkbox.on('change', function() { 216 if(this.checked) { 217 jQuery('#elex_ppct_discount_type').closest('p').show(); 218 jQuery('#elex_ppct_discount_amount').closest('p').show(); 219 } else { 220 jQuery('#elex_ppct_discount_type').closest('p').hide(); 221 jQuery('#elex_ppct_discount_amount').closest('p').hide(); 222 } 223 }); 224 if ( elex_ppct_custom_fields_discount_type_checkbox.is(':checked') ) { 225 jQuery('#elex_ppct_discount_type').closest('p').show(); 226 jQuery('#elex_ppct_discount_amount').closest('p').show(); 227 } else { 228 jQuery('#elex_ppct_discount_type').closest('p').hide(); 229 jQuery('#elex_ppct_discount_amount').closest('p').hide(); 230 } 201 }).change(); 202 231 203 }); 232 204 … … 373 345 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 374 346 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 375 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true) ;376 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true) ;377 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true) ;347 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true).prop('disabled', false); 348 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true).prop('disabled', false); 349 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', true).prop('disabled', false); 378 350 } else { 379 351 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); … … 381 353 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 382 354 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 383 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false) ;384 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false) ;385 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false) ;355 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 356 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 357 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 386 358 } 387 359 }); … … 396 368 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 397 369 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 370 371 // in intial load if the main checkbox is not checked then disable the prefix, suffix and discount checkboxs. 372 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 373 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 374 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').prop('checked', false).prop('disabled', true); 398 375 } 376 399 377 400 378 // Hide and Show prefix field 401 379 jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 402 if(this.checked){ 403 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 404 } else { 405 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 406 } 407 }); 408 if( jQuery('#elex_ppct_variation_use_prefix_id_<?php esc_attr_e( $variation->ID ); ?>').is(':checked') ) { 409 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 410 } else { 411 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 412 } 380 jQuery('.elex_ppct_variation_add_prefix_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 381 }).change(); 413 382 414 383 // Hide and Show suffix field. 415 384 jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 416 if(this.checked){ 417 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 418 } else { 419 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 420 } 421 }); 422 if( jQuery('#elex_ppct_variation_use_suffix_id_<?php esc_attr_e( $variation->ID ); ?>').is(':checked') ) { 423 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 424 } else { 425 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 426 } 385 jQuery('.elex_ppct_variation_add_suffix_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 386 }).change(); 427 387 428 388 // Hide and Show discount field. 429 389 jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 430 if(this.checked){ 431 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 432 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 390 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 391 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').toggle(this.checked); 392 }).change(); 393 394 395 jQuery('#elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>').on('change',function() { 396 const selectedVal = jQuery(this).val(); 397 const $amountField = jQuery('#elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>'); 398 if (selectedVal === 'percent') { 399 $amountField.attr('max', 100); 400 if ($amountField.val() > 100) { 401 $amountField.val(100); 402 } 433 403 } else { 434 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 435 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 404 $amountField.removeAttr('max'); 436 405 } 437 }); 438 if ( jQuery('#elex_ppct_variation_use_discount_id_<?php esc_attr_e( $variation->ID ); ?>').is(':checked') ) { 439 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 440 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').show(); 441 } else { 442 jQuery('.elex_ppct_discount_type_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 443 jQuery('.elex_ppct_discount_amount_<?php esc_attr_e( $variation->ID ); ?>_field').hide(); 444 } 406 }).change(); 407 445 408 </script> 446 409 <?php -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/readme.txt
r3383764 r3458839 3 3 Tags: before & after text, woocommerce discounts, woocommerce dynamic pricing 4 4 Requires at least: 3.0.1 5 Tested up to: 6. 86 Stable tag: 4.1. 85 Tested up to: 6.9 6 Stable tag: 4.1.9 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 59 59 == Changelog == 60 60 61 = 4.1.9 = 62 * Made compatible with WordPress 6.9 63 * Improvement and minor bug fixes 64 61 65 = 4.1.8 = 62 66 * Made compatible with WooCommerce 10.0.0 … … 228 232 == Upgrade Notice == 229 233 234 = 4.1.9 = 235 * Made compatible with WordPress 6.9 236 * Improvement and minor bug fixes 237 230 238 = 4.1.8 = 231 239 * Made compatible with WooCommerce 10.0.0 -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/vendor/autoload.php
r3383764 r3458839 15 15 } 16 16 } 17 trigger_error( 18 $err, 19 E_USER_ERROR 20 ); 17 throw new RuntimeException($err); 21 18 } 22 19 23 20 require_once __DIR__ . '/composer/autoload_real.php'; 24 21 25 return ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a::getLoader();22 return ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2::getLoader(); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/vendor/composer/ClassLoader.php
r3189599 r3458839 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 67 * @var array[] 68 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var string|null */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var array<string, self> 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param string|null $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 160 * @param string[] $classMap Class to filename map 161 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param list<string>|string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 $paths = (array) $paths; 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param list<string>|string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 $paths = (array) $paths; 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 479 * Returns the currently registered loaders indexed by their corresponding vendor directories.480 * 481 * @return self[]478 * Returns the currently registered loaders keyed by their corresponding vendor directories. 479 * 480 * @return array<string, self> 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 557 558 /** 559 * @return void 560 */ 561 private static function initializeIncludeClosure() 562 { 563 if (self::$includeFile !== null) { 564 return; 565 } 566 567 /** 568 * Scope isolated include. 569 * 570 * Prevents access to $this/self from included files. 571 * 572 * @param string $file 573 * @return void 574 */ 575 self::$includeFile = \Closure::bind(static function($file) { 576 include $file; 577 }, null, null); 578 } 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/vendor/composer/InstalledVersions.php
r3189599 r3458839 28 28 { 29 29 /** 30 * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to 31 * @internal 32 */ 33 private static $selfDir = null; 34 35 /** 30 36 * @var mixed[]|null 31 37 * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null 32 38 */ 33 39 private static $installed; 40 41 /** 42 * @var bool 43 */ 44 private static $installedIsLocalDir; 34 45 35 46 /** … … 99 110 foreach (self::getInstalled() as $installed) { 100 111 if (isset($installed['versions'][$packageName])) { 101 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);112 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; 102 113 } 103 114 } … … 120 131 public static function satisfies(VersionParser $parser, $packageName, $constraint) 121 132 { 122 $constraint = $parser->parseConstraints( $constraint);133 $constraint = $parser->parseConstraints((string) $constraint); 123 134 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 124 135 … … 310 321 self::$installed = $data; 311 322 self::$installedByVendor = array(); 323 324 // when using reload, we disable the duplicate protection to ensure that self::$installed data is 325 // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, 326 // so we have to assume it does not, and that may result in duplicate data being returned when listing 327 // all installed packages for example 328 self::$installedIsLocalDir = false; 329 } 330 331 /** 332 * @return string 333 */ 334 private static function getSelfDir() 335 { 336 if (self::$selfDir === null) { 337 self::$selfDir = strtr(__DIR__, '\\', '/'); 338 } 339 340 return self::$selfDir; 312 341 } 313 342 … … 323 352 324 353 $installed = array(); 354 $copiedLocalDir = false; 325 355 326 356 if (self::$canGetVendors) { 357 $selfDir = self::getSelfDir(); 327 358 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { 359 $vendorDir = strtr($vendorDir, '\\', '/'); 328 360 if (isset(self::$installedByVendor[$vendorDir])) { 329 361 $installed[] = self::$installedByVendor[$vendorDir]; 330 362 } elseif (is_file($vendorDir.'/composer/installed.php')) { 331 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 332 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 333 self::$installed = $installed[count($installed) - 1]; 363 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 364 $required = require $vendorDir.'/composer/installed.php'; 365 self::$installedByVendor[$vendorDir] = $required; 366 $installed[] = $required; 367 if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { 368 self::$installed = $required; 369 self::$installedIsLocalDir = true; 334 370 } 371 } 372 if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { 373 $copiedLocalDir = true; 335 374 } 336 375 } … … 341 380 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 342 381 if (substr(__DIR__, -8, 1) !== 'C') { 343 self::$installed = require __DIR__ . '/installed.php'; 382 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 383 $required = require __DIR__ . '/installed.php'; 384 self::$installed = $required; 344 385 } else { 345 386 self::$installed = array(); 346 387 } 347 388 } 348 $installed[] = self::$installed; 389 390 if (self::$installed !== array() && !$copiedLocalDir) { 391 $installed[] = self::$installed; 392 } 349 393 350 394 return $installed; -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/vendor/composer/autoload_real.php
r3383764 r3458839 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a5 class ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit f128f85d13f4c7ceefc4a739c1c0ef0a', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit82ab9e04a1db6ace9a9fec4ef697c5b2', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/vendor/composer/autoload_static.php
r3383764 r3458839 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a7 class ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( 10 'E' => 10 'E' => 11 11 array ( 12 12 'ELEX\\PPCT\\' => 10, … … 15 15 16 16 public static $prefixDirsPsr4 = array ( 17 'ELEX\\PPCT\\' => 17 'ELEX\\PPCT\\' => 18 18 array ( 19 19 0 => __DIR__ . '/../..' . '/includes', … … 28 28 { 29 29 return \Closure::bind(function () use ($loader) { 30 $loader->prefixLengthsPsr4 = ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::$prefixLengthsPsr4;31 $loader->prefixDirsPsr4 = ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::$prefixDirsPsr4;32 $loader->classMap = ComposerStaticInit f128f85d13f4c7ceefc4a739c1c0ef0a::$classMap;30 $loader->prefixLengthsPsr4 = ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::$prefixLengthsPsr4; 31 $loader->prefixDirsPsr4 = ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::$prefixDirsPsr4; 32 $loader->classMap = ComposerStaticInit82ab9e04a1db6ace9a9fec4ef697c5b2::$classMap; 33 33 34 34 }, null, ClassLoader::class); -
elex-product-price-custom-text-before-after-text-and-discount-for-woocommerce/trunk/vendor/composer/installed.php
r3383764 r3458839 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => 'c bcc4feb128503adb599b9db9b878f1662b629cd',6 'reference' => 'caf2aa1024cb5a885ff23a3a42cc8e520e3e9f5e', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => 'c bcc4feb128503adb599b9db9b878f1662b629cd',16 'reference' => 'caf2aa1024cb5a885ff23a3a42cc8e520e3e9f5e', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.