Skip to content

Commit

Permalink
Add $formatted_destination as an argument to the woocommerce_cart_no_…
Browse files Browse the repository at this point in the history
…shipping_available_html filter (woocommerce#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>
  • Loading branch information
webdados and barryhughes authored Nov 23, 2022
1 parent 527249f commit 085149a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/adjust-no-shipping-hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: tweak

Make the formatted shipping address available via the `woocommerce_cart_no_shipping_available_html` hook.
20 changes: 17 additions & 3 deletions plugins/woocommerce/templates/cart/cart-shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) );
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' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ),
$formatted_destination
)
);
$calculator_text = esc_html__( 'Enter a different address', 'woocommerce' );
endif;
?>
Expand Down

0 comments on commit 085149a

Please sign in to comment.