Plugin Directory

Changeset 3411217


Ignore:
Timestamp:
12/04/2025 04:56:14 PM (4 months ago)
Author:
nakedcatplugins
Message:

Upload 2.4

Location:
free-shipping-hide-other-methods-woo/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • free-shipping-hide-other-methods-woo/trunk/free-shipping-hide-other-methods-woo.php

    r3290560 r3411217  
    44 * Plugin URI:
    55 * Description:          Alternative WooCommerce “Free Shipping” and “Flat Rate” methods that allows the shop owner to select and make unavailable any other shipping methods on the same zone when this one is available
    6  * Version:              2.3
     6 * Version:              2.4
    77 * Author:               Naked Cat Plugins (by Webdados)
    88 * Author URI:           https://nakedcatplugins.com
     
    1212 * Requires PHP:         7.2
    1313 * WC requires at least: 7.1
    14  * WC tested up to:      9.8
     14 * WC tested up to:      10.4
    1515 * Requires Plugins:     woocommerce
    1616 * License:              GPLv3
  • free-shipping-hide-other-methods-woo/trunk/includes/class-wc-shipping-flat-rate-hide-others.php

    r3188905 r3411217  
    158158     */
    159159    public static function enqueue_admin_js() {
    160         wc_enqueue_js(
     160        $handle = 'flat-rate-hide-others-admin';
     161        wp_register_script( $handle, '', array( 'jquery' ), WC_VERSION, array( 'in_footer' => true ) );
     162        wp_enqueue_script( $handle );
     163        wp_add_inline_script(
     164            $handle,
    161165            "jQuery( function( $ ) {
    162166                function wcFlatRateHideOthersShowHideMinAmountField( el ) {
    163167                    var form = $( el ).closest( 'form' );
    164                     var shippingClassField = $( '#woocommerce_flat_rate_hide_others_fso_shipping_class', form ).closest( 'tr' );
     168                    var shippingClassField      = $( '#woocommerce_flat_rate_hide_others_fso_shipping_class', form ).closest( 'tr' );
     169                    var shippingClassFieldLabel = null;
     170                    if ( shippingClassField.length === 0 ) {
     171                        var shippingClassField      = $( '#woocommerce_flat_rate_hide_others_fso_shipping_class', form ).closest( 'fieldset' );
     172                        var shippingClassFieldLabel = $( 'label[for=woocommerce_flat_rate_hide_others_fso_shipping_class]' );
     173                    }
    165174                    switch( $( el ).val() ) {
    166175                        case '':
    167176                            shippingClassField.hide();
     177                            shippingClassFieldLabel?.hide();
    168178                            break;
    169179                        case 'fsho_shipping_class':
    170180                            shippingClassField.show();
     181                            shippingClassFieldLabel?.show();
    171182                            break;
    172183                    }
     
    184195                    }
    185196                } );
    186             });"
     197            } );"
    187198        );
    188199    }
  • free-shipping-hide-other-methods-woo/trunk/includes/class-wc-shipping-free-shipping-hide-others.php

    r3188905 r3411217  
    132132     */
    133133    public static function enqueue_admin_js() {
    134         wc_enqueue_js(
     134        $handle = 'free-shipping-hide-others-admin';
     135        wp_register_script( $handle, '', array( 'jquery' ), WC_VERSION, array( 'in_footer' => true ) );
     136        wp_enqueue_script( $handle );
     137        wp_add_inline_script(
     138            $handle,
    135139            "jQuery( function( $ ) {
    136140                function wcFreeShippingHideOthersShowHideMinAmountField( el ) {
    137141                    var form = $( el ).closest( 'form' );
    138                     var minAmountField = $( '#woocommerce_free_shipping_hide_others_min_amount', form ).closest( 'tr' );
    139                     var ignoreDiscountField = $( '#woocommerce_free_shipping_hide_others_ignore_discounts', form ).closest( 'tr' );
     142                    var minAmountField      = $( '#woocommerce_free_shipping_hide_others_min_amount', form ).closest( 'tr' );
     143                    var minAmountFieldLabel = null;
     144                    if ( minAmountField.length === 0 ) {
     145                        var minAmountField      = $( '#woocommerce_free_shipping_hide_others_min_amount', form ).closest( 'fieldset' );
     146                        var minAmountFieldLabel = $( 'label[for=woocommerce_free_shipping_hide_others_min_amount]' );
     147                    }
     148                    var ignoreDiscountField      = $( '#woocommerce_free_shipping_hide_others_ignore_discounts', form ).closest( 'tr' );
     149                    var ignoreDiscountFieldLabel = null;
     150                    if ( ignoreDiscountField.length === 0 ) {
     151                        var ignoreDiscountField      = $( '#woocommerce_free_shipping_hide_others_ignore_discounts', form ).closest( 'fieldset' );
     152                        var ignoreDiscountFieldLabel = $( 'label[for=woocommerce_free_shipping_hide_others_ignore_discounts]' );
     153                    }
    140154                    var shippingClassField = $( '#woocommerce_free_shipping_hide_others_fso_shipping_class', form ).closest( 'tr' );
     155                    var shippingClassFieldLabel = null;
     156                    if ( shippingClassField.length === 0 ) {
     157                        var shippingClassField      = $( '#woocommerce_free_shipping_hide_others_fso_shipping_class', form ).closest( 'fieldset' );
     158                        var shippingClassFieldLabel = $( 'label[for=woocommerce_free_shipping_hide_others_fso_shipping_class]' );
     159                    }
    141160                    switch( $( el ).val() ) {
    142161                        case '':
    143162                        case 'coupon':
    144163                            minAmountField.hide();
     164                            minAmountFieldLabel?.hide();
    145165                            ignoreDiscountField.hide();
     166                            ignoreDiscountFieldLabel?.hide();
    146167                            shippingClassField.hide();
     168                            shippingClassFieldLabel?.hide();
    147169                            break;
    148170                        case 'fsho_shipping_class':
    149171                            minAmountField.hide();
     172                            minAmountFieldLabel?.hide();
    150173                            ignoreDiscountField.hide();
     174                            ignoreDiscountFieldLabel?.hide();
    151175                            shippingClassField.show();
     176                            shippingClassFieldLabel?.show();
    152177                            break;
    153178                        default:
    154179                            minAmountField.show();
     180                            minAmountFieldLabel?.show();
    155181                            ignoreDiscountField.show();
     182                            ignoreDiscountFieldLabel?.show();
    156183                            shippingClassField.hide();
     184                            shippingClassFieldLabel?.hide();
    157185                            break;
    158186                    }
     
    161189                $( document.body ).on( 'change', '#woocommerce_free_shipping_hide_others_requires', function() {
    162190                    wcFreeShippingHideOthersShowHideMinAmountField( this );
    163                 });
     191                } );
    164192
    165193                // Change while load.
     
    170198                    }
    171199                } );
    172             });"
     200            } );"
    173201        );
    174202    }
  • free-shipping-hide-other-methods-woo/trunk/readme.txt

    r3290560 r3411217  
    66Tested up to: 6.8
    77Requires PHP: 7.2
    8 Stable tag: 2.3
     8Stable tag: 2.4
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7373== Changelog ==
    7474
     75= 2.4 - 2025-12-04 =
     76* [DEV] Stop using `wc_enqueue_js` which is deprecated from WooCommerce 10.4
     77* [FIX] Fields not correctly hidden on the new WooCommerce admin interface
     78* [DEV] Tested with WordPress 7.0-alpha-61349 and WooCommerce 10.4.0-beta.2
     79
    7580= 2.3 - 2025-05-09 =
    7681* [NEW] We are now called Naked Cat Plugins 😻
Note: See TracChangeset for help on using the changeset viewer.