From 085149ad82ad115dac13af96c2642e176d956297 Mon Sep 17 00:00:00 2001 From: Marco Almeida Date: Wed, 23 Nov 2022 19:22:51 +0000 Subject: [PATCH] Add $formatted_destination as an argument to the woocommerce_cart_no_shipping_available_html filter (#30723) Add $formatted_destination as an argument to the woocommerce_cart_no_shipping_available_html filter. Developers should be able to access the $formatted_destination variable directly in order to return a new string to the filter including that address. * Add docblock and changelog for woocommerce_cart_no_shipping_available_html tweak. * Bump version tag for cart-shipping template. Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com> --- .../changelog/adjust-no-shipping-hook | 4 ++++ .../templates/cart/cart-shipping.php | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 plugins/woocommerce/changelog/adjust-no-shipping-hook diff --git a/plugins/woocommerce/changelog/adjust-no-shipping-hook b/plugins/woocommerce/changelog/adjust-no-shipping-hook new file mode 100644 index 0000000000000..76dc9b0a2a139 --- /dev/null +++ b/plugins/woocommerce/changelog/adjust-no-shipping-hook @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +Make the formatted shipping address available via the `woocommerce_cart_no_shipping_available_html` hook. diff --git a/plugins/woocommerce/templates/cart/cart-shipping.php b/plugins/woocommerce/templates/cart/cart-shipping.php index 134b05b3496fd..9884318207a02 100644 --- a/plugins/woocommerce/templates/cart/cart-shipping.php +++ b/plugins/woocommerce/templates/cart/cart-shipping.php @@ -14,7 +14,7 @@ * * @see https://docs.woocommerce.com/document/template-structure/ * @package WooCommerce\Templates - * @version 3.6.0 + * @version 7.3.0 */ defined( 'ABSPATH' ) || exit; @@ -66,8 +66,22 @@ elseif ( ! is_cart() ) : echo wp_kses_post( apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) ); else : - // Translators: $s shipping destination. - echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '' . esc_html( $formatted_destination ) . '' ) ) ); + echo wp_kses_post( + /** + * Provides a means of overriding the default 'no shipping available' HTML string. + * + * @since 3.0.0 + * + * @param string $html HTML message. + * @param string $formatted_destination The formatted shipping destination. + */ + apply_filters( + 'woocommerce_cart_no_shipping_available_html', + // Translators: $s shipping destination. + sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '' . esc_html( $formatted_destination ) . '' ), + $formatted_destination + ) + ); $calculator_text = esc_html__( 'Enter a different address', 'woocommerce' ); endif; ?>