WooCommerce Table Rate Shipping Builder

Build tiers by weight, subtotal or quantity and get a real shipping method, no paid extension needed.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your details

Uses your store's weight unit (Settings → Products → General) when tiering by weight, or your store currency when tiering by subtotal.

Table rate shipping method (PHP snippet)

class-wc-shipping-table-rate.php
<?php
/**
 * Table Rate Shipping: a tiered ("table rate") shipping method, tiered by total weight.
 * Registers a real WC_Shipping_Method so it appears as an option in every shipping zone,
 * the same way Flat Rate and Free Shipping do.
 */

add_filter( 'woocommerce_shipping_methods', 'table_rate_register_shipping_method' );
function table_rate_register_shipping_method( $methods ) {
	$methods['table_rate'] = 'WC_Shipping_TableRate';
	return $methods;
}

add_action( 'woocommerce_shipping_init', 'table_rate_shipping_method_init' );
function table_rate_shipping_method_init() {

	class WC_Shipping_TableRate extends WC_Shipping_Method {

		public function __construct( $instance_id = 0 ) {
			$this->id                 = 'table_rate';
			$this->instance_id        = absint( $instance_id );
			$this->method_title       = 'Table Rate Shipping';
			$this->method_description = 'Charges a rate based on the cart\'s total weight, in tiers.';
			$this->supports = array( 'shipping-zones', 'instance-settings' );
			$this->init();
		}

		public function init() {
			$this->init_form_fields();
			$this->init_settings();
			$this->enabled = $this->get_option( 'enabled', 'yes' );
			$this->title   = $this->get_option( 'title', $this->method_title );
			add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
		}

		public function init_form_fields() {
			$this->instance_form_fields = array(
				'enabled' => array( 'title' => 'Enable/Disable', 'type' => 'checkbox', 'label' => 'Enable this shipping method', 'default' => 'yes' ),
				'title'   => array( 'title' => 'Method title', 'type' => 'text', 'default' => $this->method_title ),
			);
		}

		// Edit the tiers here, or duplicate this whole file with a different $this->id to run a second set of tiers in another zone.
		private function get_tiers() {
			return array(
			array( 'min' => 0, 'max' => 2, 'rate' => 5.99 ),
			array( 'min' => 2, 'max' => 5, 'rate' => 8.99 ),
			array( 'min' => 5, 'max' => 10, 'rate' => 12.99 ),
			array( 'min' => 10, 'max' => 999999, 'rate' => 19.99 ),
			);
		}

		public function calculate_shipping( $package = array() ) {
			$subtotal = 0.0;
			$weight   = 0.0;
			$qty      = 0;
			foreach ( $package['contents'] as $item ) {
				$weight += (float) $item['data']->get_weight() * $item['quantity'];
				$qty += (int) $item['quantity'];
			}
			$value = $weight;
			$cost  = null;
			foreach ( $this->get_tiers() as $tier ) {
				if ( $value >= $tier['min'] && $value <= $tier['max'] ) {
					$cost = $tier['rate'];
					break;
				}
			}
			if ( null === $cost ) {
				return; // No matching tier: the method won't be offered for this cart.
			}
			$rate = array(
				'id'       => $this->get_rate_id(),
				'label'    => $this->title,
				'cost'     => $cost,
				'taxes'    => '',
				'package'  => $package,
			);
			$this->add_rate( $rate );
		}
	}
}

4 tiers built from your table. Add the snippet with a code snippet plugin or your child theme's functions.php, then add "Table Rate Shipping" to a shipping zone at WooCommerce → Settings → Shipping.

This registers a genuine WC_Shipping_Method (the same base class Flat Rate and Free Shipping use), not a filter bolted onto another method, so it shows its own settings screen and works with shipping zones normally.

This is a starting point, not a full replacement for the paid WooCommerce Table Rate Shipping extension: it doesn't have an admin settings screen for the tiers themselves (they're hard-coded here) and it applies the same tiers in every zone it's added to.

A real shipping method, not a filter hack

WooCommerce doesn't ship a free "table rate" method out of the box; the official one is a paid extension. This tool generates the same kind of thing WooCommerce's own Flat Rate and Free Shipping methods are built from: a WC_Shipping_Method class, registered through the woocommerce_shipping_methods filter and woocommerce_shipping_init action, with a calculate_shipping() method that reads the cart and calls add_rate().

Default settings

Tier by
Total weight
Tiers
0-2: 5.99, 2-5: 8.99, 5-10: 12.99, 10-999999: 19.99

A cart weighing 3.5 kg matches the 2-5 tier and shows a $8.99 shipping rate; a cart weighing 12 kg matches the top tier at $19.99.

  • Weight and quantity sum straight from the cart's line items. Subtotal uses each item's line total (price × quantity, before tax).
  • Once added to a zone, it behaves like any other shipping method: enable/disable it, rename it and reorder it against your other methods.

Adding it to your site

  1. 01

    Add the snippet

    Paste the generated PHP into a code snippet plugin, or your child theme's functions.php.

  2. 02

    Add it to a zone

    WooCommerce → Settings → Shipping, open a zone, Add shipping method, and pick the method by its title.

  3. 03

    Test with real carts

    Add products totaling different weights/subtotals/quantities to a test cart and confirm the rate changes at each tier boundary.

What this doesn't do

  • The tiers are hard-coded in the generated file, not exposed as admin settings. To run different tiers in a different zone, duplicate the file, change the class name and $this->id, and edit the tiers array.
  • It's a starting point for a store that needs tiered pricing without paying for the official extension, not a feature-for-feature replacement: it has no admin UI for editing tiers, no combining multiple bases (weight *and* subtotal) in one method, and no per-zone tier overrides without duplicating the file.
  • Always test a new shipping method on a staging site or duplicate theme before relying on it in production.

Questions people ask

Does this replace the official WooCommerce Table Rate Shipping extension?

Not fully. It covers the common case (tiers by one measure, one rate per tier) without the licence cost, but it doesn't have the extension's admin settings screen or its more advanced combinations.

Why does nothing show up in the cart sometimes?

If the cart's value falls outside every tier's min-max range (a gap in your tiers, or above your highest tier's max), the method returns no rate at all. Make sure your tiers cover 0 up to a very high number with no gaps.

Can I combine this with Free Shipping?

Yes. Add both to the same zone; WooCommerce shows every available method and lets the shopper pick, the same as with any two methods in one zone.

What weight and currency units does it use?

Whatever your store is already set to under WooCommerce → Settings → Products → General. The snippet doesn't convert units, so enter tiers in your store's own units.

Is this taxed the same as my other shipping methods?

Only if you leave "Charge tax on this shipping cost" on, which follows your Shipping tax class setting under Settings → Tax the same way Flat Rate does.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com