From c3341266eb223bf1cf40dbabf6ad80d9912d7a03 Mon Sep 17 00:00:00 2001 From: vendidero Date: Tue, 23 Apr 2024 11:04:10 +0200 Subject: [PATCH] Fix wrong class param usage when registering legacy fields. --- assets/js/static/pickup-locations.js | 4 ++-- src/PickupDelivery.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/js/static/pickup-locations.js b/assets/js/static/pickup-locations.js index 30275200..2bfe2d5c 100644 --- a/assets/js/static/pickup-locations.js +++ b/assets/js/static/pickup-locations.js @@ -16,10 +16,10 @@ window.germanized.shipments_pickup_locations = window.germanized.shipments_picku var self = germanized.shipments_pickup_locations; self.params = wc_gzd_shipments_pickup_locations_params; - var $pickupSelect = $( '#pickup_location' ); + var $pickupSelect = self.getPickupLocationSelect(); if ( $pickupSelect.length > 0 ) { - self.pickupLocations = $pickupSelect.length > 0 ? $pickupSelect.data( 'locations' ) : {}; + self.pickupLocations = $pickupSelect.data( 'locations' ); $( document.body ).on( 'updated_checkout', self.afterRefreshCheckout ); $( document ).on( 'change', '#pickup_location_field #pickup_location', self.onSelectPickupLocation ); diff --git a/src/PickupDelivery.php b/src/PickupDelivery.php index bcd35648..9de1ebd0 100644 --- a/src/PickupDelivery.php +++ b/src/PickupDelivery.php @@ -76,7 +76,7 @@ public static function register_pickup_location_customer_number_field( $field, $ 'current_location' => null, 'required' => false, 'hidden' => true, - 'classes' => array(), + 'class' => array(), ) ); @@ -95,7 +95,7 @@ public static function register_pickup_location_customer_number_field( $field, $ $args['return'] = true; if ( $args['hidden'] ) { - $args['classes'][] = 'hidden'; + $args['class'][] = 'hidden'; } $field = woocommerce_form_field( $key, $args, $value ); @@ -114,7 +114,7 @@ public static function register_pickup_location_field( $field, $key, $args, $val 'required' => false, 'custom_attributes' => array(), 'hidden' => true, - 'classes' => array(), + 'class' => array(), ) ); @@ -133,12 +133,12 @@ public static function register_pickup_location_field( $field, $key, $args, $val $args['custom_attributes']['data-locations'] = wp_json_encode( $args['custom_attributes']['data-locations'] ); - if ( ! empty( $args['options'] ) ) { + if ( count( $args['options'] ) > 1 ) { $args['hidden'] = false; } if ( $args['hidden'] ) { - $args['classes'][] = 'hidden'; + $args['class'][] = 'hidden'; } $field = woocommerce_form_field( $key, $args, $value );