Skip to content

Commit

Permalink
Remove hidden classes inside modal to prevent theme issues with custo…
Browse files Browse the repository at this point in the history
…m .hidden styles. Adjust label download handler to allow specifically targeting export/default labels. Use base shipper country as fallback manufacture country.
  • Loading branch information
dennisnissle committed Jun 4, 2024
1 parent 65b5c4d commit 292d22f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions assets/js/static/pickup-locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ window.germanized.shipments_pickup_locations = window.germanized.shipments_picku
$pickupSelect = self.getPickupLocationSelect();

if ( $pickupSelect.val() ) {
$( '.pickup-location-search-actions' ).find( '.submit-pickup-location' ).show();
$( '.pickup-location-search-actions' ).find( '.submit-pickup-location' ).removeClass( 'hidden' ).show();
} else {
$( '.pickup-location-search-actions' ).find( '.submit-pickup-location' ).hide();
$( '.pickup-location-search-actions' ).find( '.submit-pickup-location' ).addClass( 'hidden' ).hide();
}
},

Expand Down Expand Up @@ -112,7 +112,7 @@ window.germanized.shipments_pickup_locations = window.germanized.shipments_picku
$notice.find( '.currently-shipping-to' ).show();
$notice.find( '.choose-pickup-location' ).hide();

$( '#wc-gzd-shipments-pickup-location-search-form .pickup-location-remove ' ).show();
$( '#wc-gzd-shipments-pickup-location-search-form .pickup-location-remove' ).removeClass( 'hidden' ).show();
} else {
$current.attr( 'data-current-location', '' );
$current.val( '' );
Expand All @@ -123,7 +123,7 @@ window.germanized.shipments_pickup_locations = window.germanized.shipments_picku
$( '.wc-gzd-shipments-managed-by-pickup-location' ).find( 'input[type=text]' ).val( '' );
$( '.wc-gzd-shipments-managed-by-pickup-location' ).find( ':input' ).prop( 'readonly', false );

$( '#wc-gzd-shipments-pickup-location-search-form .pickup-location-remove ' ).hide();
$( '#wc-gzd-shipments-pickup-location-search-form .pickup-location-remove' ).addClass( 'hidden' ).hide();

$( '.wc-gzd-shipments-managed-by-pickup-location' ).removeClass( 'wc-gzd-shipments-managed-by-pickup-location' );
$( '.wc-gzd-shipments-managed-by-pickup-location-notice' ).remove();
Expand Down
8 changes: 4 additions & 4 deletions src/Labels/DownloadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public static function download_bulk_export() {
if ( wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'download-export-shipment-label' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$args = array(
'force' => isset( $_GET['force'] ) ? wc_clean( wp_unslash( $_GET['force'] ) ) : 'no', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
'path' => isset( $_GET['print'] ) ? wc_clean( wp_unslash( $_GET['print'] ) ) : 'no', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
);

$args = self::parse_args( $args );
Expand All @@ -53,6 +52,7 @@ public static function download_label() {
$args = self::parse_args(
array(
'force' => wc_string_to_bool( isset( $_GET['force'] ) ? wc_clean( wp_unslash( $_GET['force'] ) ) : false ),
'type' => isset( $_GET['type'] ) ? wc_clean( wp_unslash( $_GET['type'] ) ) : '',
)
);

Expand All @@ -63,8 +63,8 @@ public static function download_label() {

if ( $has_permission ) {
if ( $label = $shipment->get_label() ) {
$file = $label->get_file( $args['path'] );
$filename = $label->get_filename( $args['path'] );
$file = $label->get_file( $args['type'] );
$filename = $label->get_filename( $args['type'] );

if ( file_exists( $file ) ) {
self::download( $file, $filename, $args['force'] );
Expand All @@ -80,7 +80,7 @@ public static function parse_args( $args = array() ) {
$args,
array(
'force' => false,
'path' => '',
'type' => '',
)
);

Expand Down
2 changes: 1 addition & 1 deletion src/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function get_manufacture_country( $context = 'view' ) {
}

if ( '' === $data && 'view' === $context ) {
return wc_get_base_location()['country'];
return Package::get_base_country();
}

return $data;
Expand Down
4 changes: 4 additions & 0 deletions src/ShipmentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ public function get_manufacture_country( $context = 'view' ) {
$prop = $legacy;
}

if ( 'view' === $context && empty( $prop ) ) {
$prop = Package::get_base_country();
}

return $prop;
}

Expand Down

0 comments on commit 292d22f

Please sign in to comment.