Allow Flat Rate for Per Product Shipping packages

Allow a configured Flat Rate method to be considered for packages created by Per Product Shipping.

Note:

This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.

Back up your site and test custom code on a staging site. Set up Per Product Shipping as a standalone method and add a Flat Rate method to the applicable shipping zone before testing. Add the snippet using a site-specific plugin or another method that keeps customizations separate from your theme.

Allow Flat Rate for per-product packages

↑ Back to top

Add this PHP snippet:

add_filter(
	'woocommerce_per_product_shipping_ship_via',
	function ( $ship_via ) {
		$ship_via[] = 'flat_rate';
		return $ship_via;
	}
);

The filter adds Flat Rate to the method IDs allowed for packages split by Per Product Shipping. It doesn’t create a Flat Rate method or guarantee that one is available for every destination.

To verify the change, test a cart containing a product configured for standalone per-product shipping and enter an address in the zone where Flat Rate is enabled. Check the available shipping choices for that package. If Flat Rate does not appear, check that the method is enabled for the customer’s shipping zone and that any other shipping restrictions allow it.

Questions and support

↑ Back to top

Something missing from this documentation? Still have questions and need assistance?

  • If you have a question about an extension or theme you’d like to purchase, visit our contact page and use the AI Assistant or contact options.
  • If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.

Related Products

Advanced, flexible shipping. Define multiple shipping rates based on location, price, weight, shipping class...

Use conditional logic to restrict the shipping and payment options available on your store.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.