1. Home
  2. WooCommerce Shipping Calculator
  3. Developer Documentation

Actions and filters

There are a number of filters provided in WooCommerce Shipping Calculator which allow you to customize the behavior of the plugin.

Please note that this article is aimed at developers. If you don't know how to use this code then you should ask your developer.

We've partnered with Codeable to provide our customers with expert help if required.



Properties assigned to a global-scope variable containing WooCommerce Shipping Calculator settings passed to the front-end scripts.


  • $script_data (array): Array of WooCommerce Shipping Calculator parameters.


add_filter( 'wsc_script_params', function( $script_data ) {
	// your code to alter $script_data here...

	return $script_data;


Filter to determine whether to load the plugin styles or not.
add_filter( 'wsc_load_styles', '__return_true' );


Filter to determine whether to load the plugin scripts or not.
add_filter( 'wsc_load_styles', '__return_true' );


Filter to change the position of the shipping calculator by chosing a specic theme template action hook.
add_filter( 'wsc_shipping_calculator_position_action', function( $action ) {
	// Above the add to cart button on the Storefront theme.
	return 'woocommerce_single_product_summary';
} );


Filter to change the priority of the above action hook that determinies position of the shipping calculator on the theme template.
add_filter( 'wsc_shipping_calculator_position_priority', function( $priority ) {
	// Above the add to cart button on the Storefront theme.
	return 29;
} );


Filter to change the output of the shipping_calculator shortcode..
add_filter( 'wsc_shipping_calculator_shortcode_output', function( $out ) {
	return $out;
} );


Filter that determines if the shipping calculator should be loaded using AJAX.
add_filter( 'wsc_load_using_ajax', function( $load_using_ajax ) {
	if ( ! is_user_logged_in() ) {
		$load_using_ajax = true;
	return $load_using_ajax;
} );


Filter that determines if the current page is a product page where the shipping calculator can be shown.
add_filter( 'wsc_is_shipping_calculator', function( $is_shipping_calculator ) {
	if ( is_product() ) {
		return true;
	return $is_shipping_calculator;
} );


Filter that determines whether the current ajax call is made by the product page shipping calculator.
add_filter( 'wsc_is_shipping_calculator_ajax_call', function( $is_ajax_call ) {
	if ( isset( $_REQUEST[ 'wsc' ] ) ) {
		return true;
	return $is_ajax_call;
} );


 The ajax url argument that is used to trace the shipping calculator ajax calls.
add_filter( 'wsc_ajax_url_arg', function( $ajax_url_arg ) {
	return 'wsc';
} );


Filter to change a WooCommerce Shipping Calculator setting.

Available settings:

  • <setting> (string): label, position or expand.
add_filter( 'wsc_setting_position', function( $value, $setting ) {
	// Gets the stored setting value from the database.
	$value = get_option( 'wsc_' . $setting );

	// Do something.
	$value = 'above_title';

	return $value;
}, 10, 2 );


Filter to change the admin WooCommerce settings fields.
add_filter( 'woocommerce_get_settings_calculator', function( $plugin_settings ) {
	return $plugin_settings;
} );


Filter to change the shipping calculator position actions hooks and respective priorities.
add_filter( 'wsc_shipping_calculator_position_action_mapping', function( $position_action ) {
	$position_actions['above_title'] = 'woocommerce_single_product_summary:4';
	return $position_action;
} );


Filter to allow the selection of the shipping method within the shipping calculator.
add_filter( 'wsc_select_shipping_method', '__return_true' );


Filter to add extra classes to the main shipping calculator div.
add_filter( 'wsc_shipping_totals_class', function( $position_action ) {
	return 'my-custom-css-class';
} );




Fired before the shipping calculator is displayed.
This hook is used to estimate the shipping before shipping calculator is displayed.


Fired after the shipping calculator is displayed.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.