NEWDiscoverShipGoal– turn cart progress into bigger baskets
All articles

Target shipping methods with product or variant metafields

Use a metafield when you need to group many products or variants for a shipping rule. You give each product or variant a value, like bulky or frozen, in Shopify. A ShipWith rule then checks that value at checkout.

This works well for large catalogs. Picking hundreds of variants one by one in a rule is slow, and a rule can only hold a limited number of picked products. A metafield keeps the rule short no matter how many variants you tag.

Metafield conditions run on Catalog input. When you add one, ShipWith moves the rule to Catalog input for you.

Before you start: add the metafield in Shopify

You only do this once.

  1. In Shopify admin, go to Settings > Metafields and metaobjects.
  2. Choose Variants to set a value per variant, or Products to set one value for the whole product.
  3. Select Add definition.
  4. Give it a name, like Shipping group. Shopify fills in the namespace and key, like custom.shipping_group. Write this down. You need it in ShipWith.
  5. For the type, choose Single line text. Do not turn on List of values. ShipWith only reads single values.
  6. Save.

Fill in the values

Pick the way that fits your catalog:

  • One at a time: open a product, open a variant if needed, and fill in the metafield near the bottom of the page.
  • Bulk editor: in Products, select the products, then select Bulk edit. Add your metafield as a column and type the values. Variants show as their own rows.
  • CSV: export your products, fill in the metafield column, and import the file again. Test with a few products first.

Use the same spelling for every product in a group. ShipWith ignores upper and lower case and extra spaces, but bulky and bulky items are different values.

Create the rule

  1. Create a shipping rule.
  2. Under When the rule runs, select When set conditions are met.
  3. Add a Variant metafield or Product metafield condition. Use the same level you picked when you added the metafield. ShipWith moves the rule to Catalog input.
  4. In Metafield (namespace.key), enter the namespace and key, like custom.shipping_group.
  5. Choose an operator. The options below are for Variant metafield. Product metafield has the same options, with "products" in place of "variants".
    • cart has at least one variant with value matches when any variant in the cart has one of your values.
    • cart has only variants with value matches when every variant in the cart has one of your values. A variant with a different value, or no value, stops the match.
    • cart has no variants with value matches when no variant in the cart has one of your values. A variant with no value doesn't count as a match, so it doesn't stop this one.
  6. Type each value and press Enter. Each value becomes a chip.
  7. Add an action, like Hide specific delivery method(s) with express.
  8. Set Status to Test and check a real checkout before you go Live. See "Test your shipping rules at checkout".

Catalog input also has cart subtotal, cart total, cart quantity, quantity per line, customer tag, shipping country, province code, and ZIP code conditions. Add them to the same group to narrow the rule. Other conditions, such as Cart contains, show greyed out under Can't be combined with your existing conditions once the rule has a metafield condition.

Example: hide express shipping for bulky items

Your variants have a Shipping group metafield (custom.shipping_group) with values like bulky, standard, and fragile.

  • Condition: Variant metafield, custom.shipping_group, cart has at least one variant with value, bulky
  • Action: Hide specific delivery method(s), express

Any cart with one bulky variant no longer sees express shipping.

Limits

  • One metafield per level. All your Live and Test Catalog input rules share one variant metafield and one product metafield. For example, every variant rule must use custom.shipping_group. If two rules use different variant metafields, the sync fails and ShipWith tells you which ones clash. Use different values of the same metafield instead.
  • Single line text only. List metafields, numbers, and other types do not match.
  • Exact values. A value matches only when the whole text is the same, ignoring case and extra spaces. There is no "contains" check.
  • Missing values never match. A variant or product without the metafield does not count as having any value.
  • Catalog input only. Metafield conditions only work with Catalog input, so they cannot be combined with conditions that Catalog input does not support. Those show greyed out under Can't be combined with your existing conditions.

Troubleshooting

  • The rule never runs: check the namespace and key for typos. They must match the definition in Shopify exactly, with one dot between them.
  • It works for some products only: open a product that fails and check its metafield value. Look for a different spelling or a value on the wrong level (product instead of variant).
  • The sync failed: read the error on the rule page. If it says Catalog input reads one metafield at a time, change the rules so they use the same metafield. See "Fix a rule that failed to sync with Shopify".