---
title: "Shipping Calculator developer reference"
url: "https://kestrelwp.com/docs/shipping-calculator-developer-reference/"
description: "Filters, actions, template functions and templates for placing and restyling the shipping calculator."
published: "2026-10-06T20:28:24+00:00"
modified: "2026-10-06T20:28:24+00:00"
---

Shipping Calculator’s filters, actions, template functions and templates let developers place the calculator anywhere, change where it shows, and restyle or rewrite its output. Add the snippets below in a code snippets plugin or your child theme’s `functions.php`. For everyday setup, see [Get started with Shipping Calculator](/docs/get-started-with-shipping-calculator/).

## When you’d use this

- Put the calculator in a spot the **Position** setting doesn’t offer, such as above the price.
- Hide the calculator on some products, such as gift cards or made-to-order items.
- Let shoppers pick a shipping option in the calculator.
- Change the calculator’s markup or messages.

## Place the calculator in code

### With the template function

Call `wsc_display_shipping_calculator()` where you want the calculator in a child theme template. It outputs nothing on pages where the calculator can’t show, such as a virtual product.

For example, to show it above the price in Storefront, copy `woocommerce/templates/single-product/price.php` to `storefront-child/woocommerce/single-product/price.php` and add the call before the price:

```
<?php
global $product;

wsc_display_shipping_calculator();
?>
<p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>"><?php echo $product->get_price_html(); ?></p>
```

Set **Position** to **Don’t display the shipping calculator automatically** so it doesn’t also appear in its usual place.

### With a hook and priority

For the product summary positions, `wsc_shipping_calculator_position_action` and `wsc_shipping_calculator_position_priority` change the action and priority the calculator is added to. In WooCommerce’s standard layout, the price is added to `woocommerce_single_product_summary` at priority 10, so priority 9 puts the calculator just above it:

```
add_filter( 'wsc_shipping_calculator_position_action', function( $action ) {
	return 'woocommerce_single_product_summary';
} );

add_filter( 'wsc_shipping_calculator_position_priority', function( $priority ) {
	return 9;
} );
```

These only apply when **Position** is one of the product summary positions. Many themes fire their own actions around the price; Astra, for example, fires `astra_woo_single_price_before` and `astra_woo_single_price_after`.

### As a tab next to any tab

Return a position of `before_<tab>_tab` or `after_<tab>_tab` from `wsc_setting_position`, where `<tab>` is the key of an existing product tab (`description`, `additional_information`, `reviews`, or a tab added by another plugin):

```
add_filter( 'wsc_setting_position', function( $value, $setting_id ) {
	return 'before_reviews_tab';
}, 10, 2 );
```

## Filters

### wsc\_setting\_{setting}

Filters a setting’s value: `wsc_setting_label`, `wsc_setting_position` or `wsc_setting_expand`. Arguments: the value, then the setting ID. This example shows the calculator above the add to cart button on products in one category, and leaves the setting alone elsewhere:

```
add_filter( 'wsc_setting_position', function( $value, $setting_id ) {
	if ( is_product() && has_term( 'furniture', 'product_cat' ) ) {
		return 'above_add_to_cart';
	}

	return $value;
}, 10, 2 );
```

Position values: `none`, `above_add_to_cart`, `above_meta`, `below_meta`, `before_description_tab`, `after_description_tab`, `after_additional_information_tab`, `after_reviews_tab`. Expand values: `yes` (link to expand) and `no` (always visible).

### wsc\_shipping\_calculator\_position\_action\_mapping

Filters the list of summary positions, each mapped to an `action:priority` pair. Add your own position here, then select it with `wsc_setting_position`:

```
add_filter( 'wsc_shipping_calculator_position_action_mapping', function( $mapping ) {
	$mapping['above_title'] = 'woocommerce_single_product_summary:4';

	return $mapping;
} );

add_filter( 'wsc_setting_position', function( $value ) {
	return 'above_title';
} );
```

### wsc\_shipping\_calculator\_position\_action and wsc\_shipping\_calculator\_position\_priority

Filter the action and priority for the current summary position. See [With a hook and priority](#with-a-hook-and-priority).

### wsc\_is\_shipping\_calculator

Whether the current page shows the calculator and loads its scripts. By default, true on product pages for products that need shipping, and on pages whose content contains `[shipping_calculator]`. To hide the calculator on gift cards:

```
add_filter( 'wsc_is_shipping_calculator', function( $is_shipping_calculator ) {
	if ( is_product() && has_term( 'gift-cards', 'product_cat' ) ) {
		return false;
	}

	return $is_shipping_calculator;
} );
```

### wsc\_select\_shipping\_method

Return `true` to show a radio button next to each option when more than one is available, so shoppers can choose one in the calculator. Default `false`: the options are listed without a choice.

```
add_filter( 'wsc_select_shipping_method', '__return_true' );
```

### wsc\_load\_using\_ajax

Whether the calculator reloads itself after the page loads, so cached pages show current options. Default `true`, except on pages that define `DONOTCACHEPAGE`.

### wsc\_load\_styles and wsc\_load\_scripts

Whether to load the calculator’s stylesheet and script. Both default to `true`. Return `false` from `wsc_load_styles` to style the calculator entirely with your own CSS. The calculator doesn’t work without its script.

```
add_filter( 'wsc_load_styles', '__return_false' );
```

### wsc\_script\_params

Filters the settings passed to the calculator’s script (`wsc_params`).

```
add_filter( 'wsc_script_params', function( $params ) {
	// Change $params here.
	return $params;
} );
```

### wsc\_ajax\_url\_arg and wsc\_is\_shipping\_calculator\_ajax\_call

`wsc_ajax_url_arg` filters the request argument (default `wsc`) that marks the calculator’s own AJAX requests. `wsc_is_shipping_calculator_ajax_call` filters whether the current request is one of them.

### wsc\_shipping\_totals\_class

Adds classes to the calculator’s wrapper element. Return a string of space-separated classes.

```
add_filter( 'wsc_shipping_totals_class', function( $classes ) {
	return 'my-shipping-calculator';
} );
```

### wsc\_shipping\_calculator\_shortcode\_output

Filters the HTML the `[shipping_calculator]` shortcode returns.

### woocommerce\_get\_settings\_calculator

Filters the fields on **WooCommerce » Settings » Shipping » Shipping calculator**.

### WooCommerce message filters

The calculator’s messages run through WooCommerce’s own filters, so a change applies to both the cart and the calculator: `woocommerce_shipping_estimate_html`, `woocommerce_shipping_not_enabled_on_cart_html`, `woocommerce_no_shipping_available_html` and `woocommerce_cart_no_shipping_available_html` (which also passes the formatted address).

## Actions

### wsc\_shipping\_totals\_before\_shipping

Fires inside the calculator’s table, before the shipping options. The plugin works out the estimate on this action at priority 10, so use a later priority to read it.

### wsc\_shipping\_totals\_after\_shipping

Fires inside the calculator’s table, after the shipping options.

## Template functions

- `wsc_display_shipping_calculator()`: outputs the calculator for the current page.
- `wsc_get_setting( $setting_id )`: returns a setting’s value, after its `wsc_setting_{setting}` filter. For example, `wsc_get_setting( 'position' )`.
- `wsc_load_using_ajax()`: whether the calculator reloads itself after the page loads.

## Templates

The calculator uses two templates, which you can copy to your theme to change:

- `wsc/shipping-totals.php`: the calculator’s wrapper and table. Copy it to `yourtheme/woocommerce/wsc/shipping-totals.php`.
- `wsc/cart-shipping.php`: the list of options and messages. Copy it to `yourtheme/woocommerce/wsc/cart-shipping.php`.

The address form is WooCommerce’s `cart/shipping-calculator.php`. To give the product page calculator its own version, put a copy at `yourtheme/woocommerce/wsc/shipping-calculator.php`.

## Common issues

### "Call to undefined function wsc\_is\_shipping\_calculator()" after updating

Version 2.1.0 doesn’t define `wsc_is_shipping_calculator()` or `wsc_is_shipping_calculator_ajax_call()`. If your theme calls either of them, wrap each call in a `function_exists()` check, or call `wsc_display_shipping_calculator()` on its own: it already outputs nothing where the calculator can’t show.

### My position filter doesn’t change anything

`wsc_shipping_calculator_position_action` and `wsc_shipping_calculator_position_priority` only apply to the product summary positions. For a tab, use `wsc_setting_position`; for any other spot, call `wsc_display_shipping_calculator()` from a template.

## Keep learning

- [Get started with Shipping Calculator](/docs/get-started-with-shipping-calculator/)
- [How to add custom CSS to your site](/docs/how-to-add-custom-css-to-your-site/)
