Contents

Food and treats are bought again and again. The feeding calculator tells the shopper how much their pet eats a day and how long the bag will last, then picks the delivery plan that brings the next bag before the last one runs out.

What shoppers see

On a food or treat (the product.food template):

  • Free-from chips under the price: small rounded chips with a check, such as "Grain free" and "Chicken free".
  • How long will it last?, a card under the variant picker:
    • Weight, filled in from the pet profile with a small "From Mabel" bone, and kg / lb (switching converts the number). With no pet saved, the field says "Weight" and the card says "Add a weight to see the daily amount."
    • Activity: Low, Normal or High.
    • The answer: "About 185 g a day", a meter, and "This 6 kg bag lasts about 32 days."
    • "Deliver every 4 weeks, before the bag runs out." when the product has delivery plans.
  • The purchase options as plan cards under it, with the right plan already chosen: "Every 4 weeks · $80.10 · save 10%".
  • Ingredients, the first accordion under the buy buttons.

A weight outside 0.5 to 100 kg (1 to 220 lb) gets "Add a weight between 0.5 and 100 kg." The result updates as the shopper types or chooses, and so does the plan. Choosing another bag size (variant) works out the days again. Screen readers hear "About 185 g a day. This bag lasts about 32 days." shortly after each change.

How the daily amount is worked out

The calculator reads the product's custom.feeding_guide (chapter 7), the maker's table of grams per day by weight:

  1. Between two rows it reads proportionally between them. For a weight w between the rows w₁ (g₁ grams) and w₂ (g₂ grams): g = g₁ + (w − w₁) × (g₂ − g₁) ÷ (w₂ − w₁).
  2. Below the first row it scales the first row down: g = g₁ × w ÷ w₁.
  3. Above the last row it carries on at the same rate as the last two rows, and adds "Above the maker's guide. Check with your vet."
  4. Activity: Low takes Low activity (85%) of that amount, Normal 100%, and High takes High activity (120%).
  5. Rounding: to the nearest Round the daily amount to (5 g by default): 197 g shows as 195 g. It never shows less than one step.

Then how long the bag lasts: the selected variant's custom.net_grams divided by the daily amount, rounded down to whole days: "This 6 kg bag lasts about 32 days." From 60 days it says weeks instead ("about 9 weeks"). The bag's size in the sentence comes from custom.net_grams too: 6000 shows as "6 kg", 1500 as "1.5 kg", 800 as "800 g". A variant without custom.net_grams shows the daily amount only: no days, no meter and no plan.

The meter shows the days against your longest delivery plan (or eight weeks when there are no plans): a full bar means the bag outlasts every interval.

Worked example

The guide on the bag:

Weight kg | Grams per day
2 | 55
5 | 105
10 | 165
15 | 215
20 | 265
30 | 350
40 | 430

Mabel weighs 12 kg and has normal activity. 12 kg is between 10 kg (165 g) and 15 kg (215 g), two-fifths of the way along: 165 + 2 × 50 ÷ 5 = 185 g a day, already a multiple of 5. The 6 kg bag has custom.net_grams 6000: 6000 ÷ 185 = 32.4, so it lasts about 32 days. The plans deliver every 2, 4, 6 or 8 weeks (14, 28, 42 or 56 days); the longest that comes within 32 days is 4 weeks (28 days), so Deliver every 4 weeks is chosen, and the next bag arrives four days before the last scoop.

More with the same guide:

ChangeDaily amount6 kg bag lastsPlan chosen
Low activity (85%)185 × 0.85 = 157.25, shown as 155 gabout 38 days4 weeks
High activity (120%)185 × 1.2 = 222, shown as 220 gabout 27 days2 weeks (4 weeks is 28 days, one too many)
A 2 kg bag (2000 g)185 gabout 10 days2 weeks: no plan fits, so the shortest
A 12 kg bag (12000 g)185 g64 days: "about 9 weeks"8 weeks
A 3 kg cat55 + 1 × 50 ÷ 3 = 71.7, shown as 70 gabout 85 days: "about 12 weeks"8 weeks
A 45 kg dog430 + 5 × 8 = 470 g, with "Above the maker's guide. Check with your vet."about 12 days2 weeks

Autoship: delivery plans

Scruff shows delivery plans; it doesn't create them. Plans (Shopify calls them selling plans) come from a subscription app: Shopify's free Shopify Subscriptions app, or another subscription app. The app creates the plans, takes the repeat payments, and gives shoppers the account page where they skip, swap or pause, so the feeding promo's "Skip, swap or pause from your account" is true only if your app does that.

To set up autoship:

  1. Install a subscription app from the Shopify App Store.
  2. In the app, create a plan for your food and treats with delivery every 2, 4, 6 and 8 weeks (or the intervals you offer), and any discount, such as 10%. Add your food products to it.
  3. Open a food in the theme editor: the plan cards appear under the calculator, with a plan chosen. If no plan is chosen, read on.

How the calculator knows each plan's weeks. It reads a number followed by "week", "weeks", "wk" or "wks" in the plan's name or options: "Deliver every 4 weeks", "4-week delivery" and "Every 4 wk" are all 4 weeks. A plan whose name has no number of weeks, such as "Monthly", takes its number from Weeks per delivery plan (Theme settings › Feeding and autoship) by its place in the list: with "2, 4, 6, 8", the first plan is 2 weeks, the second 4, and so on. So if your app names plans by month ("Every month", "Every 2 months"), either rename them in weeks, or set Weeks per delivery plan to match their order, such as 4, 8. A plan that ends up with no weeks is left out of the matching (shoppers can still choose it).

Which plan is chosen. The longest plan whose interval is no longer than the days the bag lasts, so the next bag lands before the last one runs out. If every plan is longer than the bag lasts, the shortest. Only plans the selected variant can be bought with count.

The shopper always wins. The calculator chooses a plan when the page opens and again when the weight, activity or bag size changes, but only until the shopper picks a purchase option themselves (one-time included); after that it never changes their choice. It never chooses over a link that names a plan (?selling_plan=). Turn Preselect the closest plan off to leave the choice to shoppers entirely: the calculator then only says which interval would suit.

No plans: the product shows no purchase options, and the calculator shows the daily amount and how long the bag lasts.

The plan cards come from the Buy buttons block's Show subscription options (chapter 6). In the bag, a line on a plan shows its plan name on a small chip ("Deliver every 4 weeks").

Settings

Theme settings › Feeding and autoship:

SettingDefaultWhat it does
Low activity85%60 to 100%, in steps of 5. Share of the guide's amount for a less active pet.
High activity120%100 to 160%, in steps of 5. Share of the guide's amount for a very active pet.
Round the daily amount to5 g1 g, 5 g or 10 g: the nearest whole number of grams
Weeks per delivery plan2, 4, 6, 8Used when a plan name has no number of weeks, in plan order, such as 2, 4, 6, 8
Preselect the closest planOnPicks the longest plan that delivers before the bag runs out, until the shopper chooses

The Feeding calculator block (Product and Featured product sections):

SettingDefaultWhat it does
Heading"How long will it last?"
Show activityOnOff hides the choice and uses Default activity (Normal unless you changed it first)
Default activityNormalLow, Normal or High. Shows while Show activity is on.
Show the meterOn

It reads the product's custom.feeding_guide (weight kg | grams per day) and each variant's custom.net_grams, and is hidden on a product without a guide.

The Free-from chips block has no settings: it shows the product's custom.free_from values, and nothing without them. The Ingredients block has a Heading ("Ingredients") and Open by default (off), and shows the product's custom.ingredients in an accordion, keeping your line breaks. It shows nothing without the metafield.

The Feeding promo section

The home page's "Never run out" band: your words on the left, and on the right a white card with one product, its compact calculator, a bag-size menu when it has variants, the delivery intervals as chips, and its own add to bag button, which reads "Add to bag · every 4 weeks" when a plan is chosen.

SettingDefaultWhat it does
BackgroundDeep band
Eyebrow"Autoship"
Heading"Never run out"
Text"Tell us how much [name] eats and we'll work out how long a bag lasts, then deliver the next one before the last scoop."[name] becomes the pet's name, or "your pet" until one is saved
Tick 1, Tick 2, Tick 3"Daily amount from the maker's feeding guide", "Delivery every 2, 4, 6 or 8 weeks", "Skip, swap or pause from your account"Three short lines with checks. State only what your subscription app actually offers. [name] becomes the pet's name, or "your pet", as in Text (the Barkery preset's first tick uses it).
Button label, Button link"Shop food and treats"Under Button. With no link, it goes to all products.
ProductUnder Calculator. The food the calculator is for. It needs a custom.feeding_guide.
Show activityOn

Until you choose a product with a feeding guide, shoppers see only the words, across the full width: no card. In the theme editor the card shows and says why. Choose your best-selling food, or delete the section.

In the theme editor

On a product without a feeding guide, the theme editor shows the calculator with the sample guide above, 6 kg bags and a "Sample" tag, and the free-from chips and ingredients with sample words, each saying shoppers won't see them. Shoppers see nothing until you fill in the metafields.