Skip to main content

Yoast og:image Not Following CDN? The indexable Cache Bypass

· 8 min read

While doing the final verification pass on a CDN migration for a client site, a full crawl of 233 pages turned up 95 files whose og:image still pointed at the pre-migration domain and returned 404 — on the same pages where twitter:image and JSON-LD images were already serving the CDN domain. The rewrite pipeline covered the attachment output path, yet the social card image slipped through alone. This post records the diagnosis and the fix.

TL;DR​

  1. Yoast SEO (verified on 28.2) picks og:image through add_from_indexable, which consumes the open_graph_image_meta cache string first. The old domain lives inside that cached string and is returned verbatim — the WP attachment API is never touched, so URL rewrites attached to the attachment layer cannot intercept it.
  2. Two-step fix: hook a domain-swap callback on the wpseo_opengraph_image filter (shipped as 0.5.0 and deployed to both sites), then clear the cache with echo y | wp yoast index --reindex. Verification: all 95 affected files now return 200 (95/95), and a re-crawl of 233 pages shows zero og/twitter old-domain references.

DeepSeek prompt cache misses? Audit your system segment

· 8 min read

In a Node.js + TypeScript backend calling DeepSeek through an OpenAI-compatible endpoint for structured extraction, input costs stayed high — a single request carried 40.8k input tokens with only 28% cache hits, while cached tokens are billed at roughly 1/50 of the miss price. More than 70% of our input was paying full price.

The conventional way to build such a service is to stuff system instructions, recalled reference content, and user context into the system segment. That is exactly where the problem lives — and the problem is not DeepSeek-specific: prefix caching is standard across LLM APIs, same mechanism with vendor-specific parameters. This piece is measured on DeepSeek; a cross-provider translation table closes the article.

TL;DR​

  • Measured with real requests, the render order is system → tools → messages, and cache matching walks that order as a sequential prefix. A single per-request-changing byte in the system segment invalidates the roughly 23.7k tokens of tool definitions behind it. The law is provider-independent — changing content goes last; only the render order differs (translation table at the end).
  • Moving dynamic content into messages and putting static content first recovers the hit rate. But prompt layout is also a behavior surface: our purely "cache-motivated" reorder pushed output regression dirty cases from 0 to 2.25 per round; a directed A/B confirmed causality and we rolled everything back.
  • Bottom line: segment order and instruction placement are not pure performance knobs. Freeze a behavioral baseline before you touch them.

Symptoms: the bill won't drop and the hit rate is stuck at 28%​

The usage object carries the cache-hit field — that is where the investigation starts, and it confirms the endpoint supports caching:

{
"usage": {
"prompt_tokens": 40800,
"prompt_cache_hit_tokens": 11424
}
}

prompt_cache_hit_tokens divided by prompt_tokens is the hit rate. Our extraction calls carried 40.8k input tokens with the rate hovering around 28% — no sampling tweak changed it, and the cache-miss share simply refused to fall. With DeepSeek billing hits at roughly 1/50 of the miss price, raising the hit rate was the most obvious money on the table.

Root cause: per-request content lives in the system segment​

The measured render order is system → tools → messages, and cache matching walks that order as a sequential prefix — whatever sits behind the changing content loses its cache. Armed with that hypothesis, two easy suspects came first:

  1. Tool definitions too large? They are static and byte-identical across requests, so in theory they should share a prefix — on their own they introduce no change.
  2. Endpoint lacks caching? The usage object has prompt_cache_hit_tokens, and consecutive requests in the same conversation saw hits rise — the mechanism works; the prefix just keeps getting "polluted".

That left the parts of the request that actually change. Six real requests, varying one segment at a time and watching where the hit boundary landed, gave the render order:

Request render order:  system  →  tools  →  messages
↑
Prefix matching proceeds segment by segment; the break lands at the
end of the first segment that changes. One token of change in system
and everything behind it — tools (~23.7k tokens) and messages — is
billed as a miss.

Our system segment mixed three kinds of per-request content: injected recall blocks, user context, and session state. Each one refreshed the prefix and dragged the 23.7k tokens of tool definitions down with it.

Structured calls on DeepSeek hide another trap — the call succeeds but returns empty when thinking mode consumes the output budget; worth checking while you are in there.

The reorder experiment: cache recovered, behavior jittered​

The reorder recovered the hit rate, and the behavioral regression judge rejected the whole approach. The fix itself is standard — rebuild a shared prefix:

New assembly order:
system = static instructions + few-shot examples ← byte-identical, shared
tools = tool definitions, placed first ← prefix continues
messages = recall blocks / user context / session state ← all dynamic content here

The cache side improved as expected. Then we ran the behavioral regression — a fixed replay sample set, executed before and after the change, comparing whether outputs stayed within expected shapes:

  • Baseline before the change: 3 replay rounds, 315 calls, 0 dirty cases;
  • After the reorder: the same judge produced 2.25 dirty cases per round on average — fixed-format boundary sentences in the output started wobbling, sometimes present, sometimes not, for the same kind of input;
  • Suspecting test flakiness: we ran a two-environment comparison with the old commit checked out via git worktree; the pre-change side stayed at 0, so the difference was real and caused by the change;
  • Directed A/B: 6 boundary-sentence cases replayed on both sides flipped 0/6 → 2/6, pinning causality on the reorder;
  • Compromise variant: keeping only the mode directive in its original position still accumulated 6 dirty cases over 3 rounds — there is no safe partial reorder.

We rolled back everything and the regression went green again. The rollback is not the end of the story: the hit-rate problem remains, and our troubleshooting notes now record what evidence a retry requires — an extract-only variant passing the full judge, plus a full probe re-run. Neither, no restart.

The arithmetic: a 1/50 hit-to-miss price ratio is tempting, but the savings have to be weighed against the debugging cost of an output-quality regression and the wobble users actually see. Before the behavioral gates are in place, that trade is not worth it.

This "every prompt-surface change must pass the behavioral gates first" process now runs continuously in production for Life, an AI money-and-mood journal — talk naturally to record expenses, with end-to-end encryption protecting privacy.

Caveats

  • "Layout only, no semantic change" is an illusion. Moving instructions is enough to change a model's output discipline; treat cache optimization as a behavior change and run it through the same regression gate.
  • Freeze the baseline first. A fixed replay sample set with judges, executed identically before and after — without a baseline you cannot separate flakiness from regression.
  • Verify cache and behavior separately. Cache first (same request repeatedly, watch hits rise), then behavior in its own run — never mix them in one round.
  • Cache entries have a retention window and expire once a prefix goes unused. Low-traffic services see naturally lower hit rates; confirm your traffic pattern before optimizing.

LLM output is uncontrollable at the best of times; our notes on silent Function Calling failures cover the same family of problems — enum drift and prompt bloat that never crash, just quietly degrade.

Boundary: does this hold beyond DeepSeek?​

The mechanism and the discipline transfer; the parameter table does not — "per-request-changing content goes last" is the only rule that survives untouched.

DeepSeek (measured here)OpenAIAnthropicGemini
Activationautomaticautomatic, ≥1024 tokensexplicit cache_control breakpoints, ≤4automatic (2.5 series+), ≥2048 tokens
Usage fieldprompt_cache_hit_tokensprompt_tokens_details.cached_tokenscache_read_input_tokensusage.total_cached_tokens
Hit discount≈1/50 (measured)up to 90%, ≈1/101/10automatic savings on hits

Three spots where blind copying bites:

  • Render order is per-provider. The system→tools→messages order here is only measured on DeepSeek: Anthropic's docs state the cached prefix is assembled tools → system → messages, and OpenAI's structured outputs schema also renders ahead of the system message. Whichever segment renders first is the one that must stay byte-static — per-request content in the leading segment breaks everything behind it on every provider, but which segment leads differs.
  • Activation gates and breakpoints. DeepSeek, OpenAI, and Gemini cache automatically; Anthropic requires manual breakpoints, with dynamic content placed after the last one — without a breakpoint there is nothing to hit.
  • Caching doesn't change output; reordering does. OpenAI's and Anthropic's docs both state that output stays identical on a cache hit. No conflict with this article: what changes behavior is the reorder made to earn hits — the token sequence itself moves, and the model follows. Charge the bill to the reorder, not the cache.

FAQ​

What is DeepSeek prompt caching?​

It is the portion of your input billed at the cached rate, reported as prompt_cache_hit_tokens over prompt_tokens in the usage object. Hits cost roughly 1/50 of the miss price. At 40.8k input tokens per request with a 28% hit rate, over 70% of our input was billed at full price.

Why is my DeepSeek cache hit rate so low?​

Most often the system segment contains per-request content. The measured render order is system→tools→messages and prefix matching is sequential, so one changing token in system cuts the ~23.7k tokens of tool definitions behind it. Move dynamic content into messages — and treat the reorder as a behavior change, because ours raised regression dirty cases from 0 to 2.25 per round.

How long does the DeepSeek prompt cache live?​

Cache entries have a retention window and expire once a prefix goes unused, so low-traffic services see naturally lower hit rates. Confirm your traffic pattern before optimizing; beyond that, sequential prefix matching over system→tools→messages decides the outcome.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

Aliyun Assistant Kills nohup Jobs? Escape with setsid

· 6 min read

While using Aliyun Cloud Assistant RunCommand to start an strace sampler, a watch loop and a periodic sampler on a server, the background jobs were silently reaped the moment the call returned — the output was an empty file, or a half file with exactly one sample, and nothing ever logged an error.

Ran into this while providing managed hosting for a WordPress site in China — full-site migration, image CDN offload, daily backups and automated patrols.

TL;DR​

When a Cloud Assistant invocation ends, the agent cleans up the background processes derived from it, and nohup does not save them — it only ignores SIGHUP and redirects output, leaving the process in the original session, right inside the cleanup's reach. A new session via setsid is what escapes: setsid nohup cmd < /dev/null &. And before reading results back, verify the output file's line count and mtime — do not read an empty file as "the command never ran".

Symptoms: the call returns, the background jobs vanish​

Background jobs started with nohup cmd & inside one RunCommand invocation died in three different shapes:

JobHow it died
strace samplerOutput file never created at all
Periodic sampler v1Wrote exactly one sample, then nothing
cpdavd watcher, first versionReaped; process gone

All three share two traits: the invocation itself returned Success, and the server logged no error anywhere. Searching "nohup process disappeared" mostly points at SIGHUP — but nohup was already in place.

Root cause: nohup never changes the session, and cleanup sweeps by session​

nohup's contract is two lines long: ignore SIGHUP, redirect output to nohup.out. What it does not do is change the session — the process stays inside the session the Cloud Assistant agent created for this invocation. When the invocation finishes, the agent cleans up the processes derived from it, grouped by session, and nohup jobs fall squarely inside.

setsid is the semantics that actually addresses this: it puts the new process into a brand-new session, detached from the invocation's. Detached, the end-of-invocation sweep never reaches it — verified across all three job types, all of which survived once setsid went in.

One honest boundary: whether the agent sweeps by process group or by session was not verified at source level. But "leave the original session and you survive" held as a sufficient condition on every job tested, and that is enough.

Fix: the setsid three-piece form, plus output verification​

Detaching from session, terminal and foreground in one line:

# Long-running job started from inside a Cloud Assistant script (sampler example)
setsid nohup /usr/local/bin/sampler --interval 60 -o /tmp/samples.csv </dev/null >/tmp/sampler.log 2>&1 &

Do not drop </dev/null — a background job whose stdin still hangs on the invocation's terminal semantics can survive the cleanup and still stall.

Cloud Assistant is asynchronous in three steps (CreateCommand → InvokeCommand → DescribeInvocationResults); fetch results about 10 seconds after invoking, and let the script exit normally after spawning the background job — no waiting required.

Before reading results back, verify the job actually lived:

# Line count should match the expected sample count; mtime should keep advancing
wc -l /tmp/samples.csv
stat -c %Y /tmp/samples.csv

An empty file or a single sample means the job died — go check the setsid form, not the business command. This "spawn remotely, read back later, verify output first" loop, combined with Cloud Assistant's ActionTrail audit trail, is a complete emergency-diagnostics workflow.

The lesson also explains the architecture behind CCLee Server Sentinel, a Linux server monitoring service: collection runs through a resident agent and local cron on each machine, and backup scripts run locally without depending on a central server — a long-lived job's lifecycle should never be bound to the tail end of a single remote invocation.

Note

The verified form is setsid nohup cmd < /dev/null &, and each piece does one job: setsid changes the session, nohup covers SIGHUP and output, stdin redirection cuts terminal semantics. Put output verification before the read-back — the invocation's Success only means the script finished, not that the background job is alive. And since a setsid job has left the invocation's session, later invocations cannot manage it directly; leave a PID file or locate it by process name.

Untrustworthy signals come in sets on Cloud Assistant: CLI errors go to stderr with exit 0, and a jq fallback default launders the failure into an empty result — see Aliyun CLI Exit 0 but Failed? jq Default Values Hide Errors.

FAQ​

Why did my nohup process disappear anyway?​

nohup does exactly two things: ignore SIGHUP and redirect output. The process stays in the original session, and Cloud Assistant cleans up the invocation's derived processes by session when the call ends — in one verified case strace, a sampler and a watcher all died while the invocation itself returned success with no error. A new session via setsid is what escapes the cleanup.

A nohup job quits after running for a while — what's going on?​

Three usual causes: the launcher's session being torn down, stdin still attached to a closed terminal, or a vanished redirect target. Check the timing: the sampler in this case stopped after exactly one sample, in sync with the invocation returning — that pinned the cause to invocation cleanup, not a crash.

How do I keep a script running in the background of a Cloud Assistant RunCommand?​

Use the three-piece form: setsid nohup cmd < /dev/null &. The new session is outside the end-of-invocation cleanup, so the job survives across calls. Before reading results, check the output file's line count and mtime — an empty or half-filled file means the job died, not that the command never ran.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

WPML Switcher Not Changing? do_shortcode_tag Never Fires

· 8 min read

While reworking the header of a WordPress site — replacing the WPML language switcher with a single text link — the do_shortcode_tag filter I hooked changed nothing on the page: no error, no log entry, no cache to clear.

Ran into this while providing managed hosting for a WordPress site in China — full-site migration, image CDN offload, daily backups and automated patrols.

TL;DR​

The WPML 4.9.x language switcher never touches the WordPress shortcode pipeline: its shortcode_actions slot has no add_shortcode registration, and the HTML is rendered directly by the theme's header builder, so do_shortcode_tag never fires for it. To change the rendered output, the only place that works regardless of render path is the output buffer — hook ob_start on template_redirect and run bounded, anchor-based replacements. Every page ends up with exactly one header link, and rolling back means deleting one mu-plugin file.

Symptoms: the filter is hooked, the page ignores it​

Once the mu-plugin lands, the page renders the switcher exactly as before — no error, no log entry, no cache to clear.

The code looks unimpeachable — hook the filter, match the tag, replace the output:

add_filter( 'do_shortcode_tag', function ( $output, $tag ) {
if ( 'wpml_language_switcher' === $tag ) {
// replace switcher markup
return my_replace_switcher( $output );
}
return $output;
}, 10, 2 );

Searching "do_shortcode_tag not working" or "filter has no effect" mostly surfaces priority and argument-count advice; none of it helps.

Two usual suspects drop out quickly: there is no page-cache layer (origin responds with no-cache, and the public HTML is byte-identical to the origin), and the filter function itself is fine — calling it directly under wp eval returns the expected replacement markup. The function works, no cache exists, the page ignores it — the problem has to be further upstream.

Root cause: the WPML switcher bypasses the shortcode pipeline​

do_shortcode_tag lives in the core shortcode parsing loop; it only fires for markup that actually goes through do_shortcode().

Reading WPML 4.9.6 source: the switcher's shortcode_actions slot (classes/language-switcher/slots/class-wpml-ls-shortcode-actions-slot.php) never registers an add_shortcode, and its render method is invoked directly by the theme's header builder. On the other side, the theme (Impreza) contains zero do_shortcode references to this slot. With both ends disconnected, the shortcode pipeline simply isn't part of this HTML's birth path — and a filter on that pipeline waits forever.

Not a cache issue, not a priority issue, not a callback-signature issue: the filter is never called at all. The wp eval test produced a false signal precisely because it tests the function, not the pipeline.

Four false leads​

Cache first. CDN and page-cache layers checked — origin no-cache, public bytes identical to origin. Not a wrong direction, but it cost a round; confirming whether shortcodes participate in the render path should have come first.

The wp eval false positive. Calling the filter function directly returned the correct replacement markup, so "the function works" steered the hunt toward caching and priorities. In hindsight, a unit test proves nothing about the request path — same lesson as the plugin PDF download 500: the context wp eval loads is not the context a real request walks.

Zero hits on a full-database search. The handover notes said the switcher's host element carried the class ush_html_1; a wp db search across every table found 0 hits for that literal — one step from declaring the notes wrong. Reality: Impreza assembles element classes at runtime as ush_ + type + index, and the literal is never written to the database. To decide whether an element exists, read the rendered HTML; don't grep the database.

The "three flags" illusion. The requirement spoke of three language flags in the header; the WPML switcher renders only two (EN/BR). Grabbing every img tag on the page revealed the third "Chinese flag" as an independent media-library image element — a redundant self-link back to the site's own Chinese homepage, nowhere near the switcher block. When auditing header elements, dump the full img list first and classify second; don't stay trapped inside one component's markup.

Side pit: hand-calling apply_filters takes all 4 arguments​

A test fixture calling apply_filters( 'do_shortcode_tag', $out, $tag ) with 2 arguments died with ArgumentCountError on the spot. Reason: the instagram-feed plugin hooks the same filter with a callback requiring exactly 4 arguments (a cron status check), and an under-argued invocation fatals.

Production never trips this — core always passes 4 arguments. Only wp eval-style fixtures do, so fixtures should use the full form:

apply_filters( 'do_shortcode_tag', $out, $tag, '', '' );

Fix: bounded anchor replacement in the output buffer​

If the render layer can't be changed, change the final HTML after rendering: hook ob_start on template_redirect and run anchor-based regex replacements in the callback. The output buffer is indifferent to render paths — directly-rendered HTML passes through it too, which is exactly why this works.

Four design constraints:

  1. Front-end only: admin, ajax, cron and REST all bypass
  2. HTML guard: output without <html or <!doctype (feeds, JSON) is never touched
  3. Anchors must be stable features of the rendered markup (image filenames, aria-labels); bounded regex consumes only the anchor's block
  4. Idempotence: replacement output never contains its own anchors, so repeated runs don't stack
<?php
/**
* Plugin Name: Header Link Replace
* Description: Replace header language elements with a single text link via output buffering. Rollback = delete this file.
* Version: 1.0.0
*/

defined( 'ABSPATH' ) || exit;

function hlrep_link_html() {
return '<a href="https://example.com/en/" hreflang="en" lang="en" aria-label="English site" style="text-decoration:none;color:inherit">EN</a>';
}

function hlrep_buffer_start() {
if ( is_admin() || wp_doing_ajax() || wp_doing_cron() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
return;
}
ob_start( 'hlrep_buffer_flush' );
}

function hlrep_buffer_flush( $html ) {
if ( ! is_string( $html ) || '' === $html ) {
return $html;
}
if ( false === stripos( $html, '<html' ) && false === stripos( $html, '<!doctype html' ) ) {
return $html; // feeds/JSON etc. stay untouched.
}
$en = hlrep_link_html();
$done = 0;
if ( false !== stripos( $html, 'flag-cn.png' ) ) {
// (1) Swap the flag element in place: replace only the <a><img></a> anchor, keep the wrapper div.
$html = (string) preg_replace(
'#<a[^>]*>\s*<img[^>]*flag-cn\.png[^>]*/?>(?:\s*</a>)#is',
$en,
$html,
1,
$done
);
}
if ( false === stripos( $html, 'aria-label="Language Switcher"' ) ) {
return $html;
}
// (2) Switcher block: with (1) present, blank it to avoid a double link; otherwise fall back to the link.
$html = (string) preg_replace(
'#<div[^>]*aria-label="Language Switcher"[^>]*>.*?</div>#is',
$done ? '' : $en,
$html,
1
);
return $html;
}
add_action( 'template_redirect', 'hlrep_buffer_start', 1 );

Division of labor between the two anchors: on pages with a flag image, the link lands in the flag's original spot (only the <a><img></a> anchor is replaced; the wrapper div stays, so the position holds) and the switcher block is blanked to prevent a duplicate; on pages without a flag, the fallback branch puts the link where the switcher was. Together, every page ends up with exactly one header link.

This went through three iterations: v1.0 was a single-anchor replacement of the switcher — through the very filter pipeline that got falsified, so it failed outright; v1.1 moved to the output buffer but only handled the flag image, leaving flag-less pages without the link; v1.2 added the dual-anchor fallback and closed the loop. The single-anchor version passed functional checks; its gap was page coverage — acceptance lists must include the flag-less pages.

Deployment and verification: pass php -l before the file lands in wp-content/mu-plugins/; the verification metric is anchor counting on rendered HTML — flag 0, switcher marker 0, target link 1. Rollback equals renaming the file, zero database changes. The site also runs a sibling ob mu-plugin (font-domain rewrite); the two layers stack and regress cleanly — output buffers nest, and each handles its own anchors.

Note

Anchors must come from measured rendered markup (grab the HTML and confirm), never guessed from theme templates or the database — classes may be runtime-assembled, and database greps will always return 0 hits. The .*? plus "first closing tag ends the block" pattern assumes no nested same-name structure inside; verify, or switch to a safer anchor and a bounded match. Replacement output must not contain its own anchors, or stacked runs will replace twice. And since the ob layer edits final HTML, search engines and structured data see the replaced markup too — confirm that is what you want.

FAQ​

How do I customize the WPML language switcher output?​

Check your version's source first: the 4.9.6 shortcode_actions slot has no add_shortcode registration and renders directly from the header builder, so every hook on the shortcode pipeline misses it. The fallback is output buffering — hook ob_start on template_redirect and replace anchors in the final HTML.

Why doesn't the do_shortcode_tag filter fire in WordPress?​

The filter only runs for markup produced by do_shortcode(). WPML 4.9.6 registers no shortcode for its switcher slot and the theme never calls do_shortcode on it either, so the filter is simply never invoked — verify against rendered HTML, not function-level unit tests.

Why does hand-calling apply_filters('do_shortcode_tag') throw ArgumentCountError?​

Other plugins hook the same filter — instagram-feed registers a callback requiring exactly 4 arguments, so a 2-argument test call fatals. Production never hits this because core always passes 4; fixtures should call it with the full 4-argument form.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

colima delete Won't Remove Docker Volumes: Only --data Does

· 9 min read

While preparing a colima delete to reset a local Docker environment, two official statements collided: the --help text says "This deletes everything", while the official FAQ says container data "should be reinstated on colima start". Same command, two official stories — at least one is wrong.

This verification happened while maintaining a local Docker dev environment (colima 0.10.3 + docker compose on macOS) that runs a shared PostgreSQL development database.

TL;DR​

  • Since colima v0.9.0, container data (images, containers, named volumes) lives on a dedicated data disk. A plain colima delete leaves it alone, and the data comes back on the next colima start.
  • colima delete --data is the irreversible one — it deletes the data disk too.
  • The --help text still says "This deletes everything", and plenty of older tutorials describe the old behavior. Trust the behavior: back up your volumes before running any delete.
  • Where volumes actually live: ~/.colima/_lima/_disks/colima/datadisk (a 100 GiB sparse file, 1.2 GiB actual usage measured).

The symptom: two official stories that contradict each other​

colima delete's two official accounts contradict each other: --help says everything is deleted, the official FAQ says the data comes back — at least one is wrong.

colima delete --help sounds alarming:

$ colima delete --help
Delete and teardown Colima and all settings.

Use with caution. This deletes everything and a startup afterwards is like the
initial startup of Colima.

Flags:
-d, --data delete container runtime data

The official FAQ entry "How can I delete container data" tells a different story: since v0.9.0, container runtime data uses a different disk, and that disk exists to "guard against accidental data loss after deletion" — the data is reinstated on colima start, and a full wipe requires colima delete --data.

If you carry the "colima delete = volumes gone" expectation, you end up stuck in one of two situations: wanting to reset the VM (upgrade, troubleshooting) but afraid to run delete; or casually adding --data for a "cleaner" reset and later discovering how much that flag actually destroys. Search queries phrase the same question in a dozen ways — "Docker volumes lost", "volumes disappeared after colima delete", "can I recover volumes after colima delete" — and the answer depends on version and flag, not a yes/no.

Root cause: container data moved to a dedicated data disk in v0.9.0​

A colima VM has two disks, and colima delete treats them completely differently.

colima's two-disk layout: how delete and delete --data differ

Both disks are visible on the host as plain files:

# System disk: a 20 GiB raw GPT disk image holding the VM OS
$ ls -lh ~/.colima/_lima/colima/disk
-rw-r--r--@ 1 cc staff 20G Oct 19 20:57 /Users/cc/.colima/_lima/colima/disk
$ du -sh ~/.colima/_lima/colima/disk
1.4G /Users/cc/.colima/_lima/colima/disk

# Data disk: a 100 GiB sparse file that grows with container data
$ ls -lh ~/.colima/_lima/_disks/colima/datadisk
-rw-r--r--@ 1 cc staff 100G Oct 19 20:57 /Users/cc/.colima/_lima/_disks/colima/datadisk
$ du -sh ~/.colima/_lima/_disks/colima/datadisk
1.2G /Users/cc/.colima/_lima/_disks/colima/datadisk

Inside the VM, Docker's data root sits entirely on the data disk:

$ docker info --format '{{.DockerRootDir}}'
/var/lib/docker
$ colima ssh -- df -h /var/lib/docker
Filesystem Size Used Avail Use% Mounted on
/dev/vdb1 98G 1.1G 92G 2% /var/lib/docker
$ docker volume ls
DRIVER VOLUME NAME
local dev-infra_dev-pg-data

That dev-infra_dev-pg-data is the named volume of the shared PostgreSQL dev database (mounted to /var/lib/postgresql/data in compose) — every byte of it lives on /dev/vdb1, which is backed by the host's datadisk file.

At the source level (colima 0.10.3, Delete in app/app.go), the scope of --data is explicit:

// delete runtime disk if disk in use and data deletion is requested
if diskInUse && data {
log.Println("deleting container data")
if err := limautil.DeleteDisk(); err != nil {
return fmt.Errorf("error deleting container data: %w", err)
}
// ...
}

data is the --data flag. Without it, this branch never runs — what gets deleted is the VM system disk and the configuration, while the data disk file stays on the host. That is also why the FAQ wording changed: colima's own upgrade/troubleshooting docs have long recommended colima delete + colima start to rebuild the environment, and before v0.9.0 that path destroyed your data along with it. v0.9.0 split "delete the environment" from "delete the data", and the FAQ says the new layout exists to "guard against accidental data loss after deletion".

colima delete vs colima delete --data: two delete semantics​

Without --data, only the system disk goes — the data disk stays put. With --data, both go.

CommandSystem disk _lima/colima/diskData disk _disks/colima/datadiskNamed volumes
colima deletedeletedkeptback on next colima start*
colima delete --datadeleteddeletedunrecoverable

One more detail hides in the confirmation prompt: the source only adds the second confirmation — "this will delete ALL container data" — when the data disk is absent or --data was passed. A plain colima delete never shows that warning, because by design it never touches your data.

* Honest caveat: "data comes back after a plain delete" comes from the official FAQ plus the source-code branch above; no full delete→start round-trip was run on the 0.10.3 machine tested here — not worth gambling a working dev environment on. If you want to test it yourself, back up first using the next section.

Three situations still lose data:

  1. colima 0.8.x and earlier: no dedicated data disk — everything sits on the system disk, so a plain delete really does delete everything. The old advice was true in that version range.
  2. Passing --data, or manually running limactl disk delete.
  3. Skipping colima delete entirely and running rm -rf ~/.colima: the data disk file lives inside that directory — more thorough than --data, taking configuration and data alike.

The fix: back up the named volume before any delete​

The generic packing method works for any volume, any storage engine:

# Back up: pack the volume contents into the current directory
docker run --rm -v dev-infra_dev-pg-data:/data -v "$PWD":/backup alpine \
tar czf /backup/dev-pg-data-$(date +%F).tgz -C /data .

# Restore: let compose recreate the empty volume first, then unpack
docker run --rm -v dev-infra_dev-pg-data:/data -v "$PWD":/backup alpine \
sh -c 'cd /data && tar xzf /backup/dev-pg-data-2026-10-19.tgz'

For databases, prefer a logical backup — cleaner than copying the data directory and stable across versions:

# Back up (life is the actual database name in this environment — use yours)
docker exec dev-pg pg_dump -U postgres -Fc life > life-$(date +%F).dump

# Restore
docker exec -i dev-pg pg_restore -U postgres -d life < life-2026-10-19.dump

Often the real motive behind a delete is "the disk is full" — a path that needs no delete at all:

  • Reclaim at the container layer: docker system prune
  • Shrink the sparse file: colima ssh -- sudo fstrim -a (v0.5.0+ also releases unused space on restart)
  • The disk can only grow, never shrink: edit disk: in ~/.colima/default/colima.yaml, then colima restart (automatic since v0.5.3)

A four-step pre-delete checklist:

  1. colima version — confirm 0.9.0 or newer; otherwise treat it as the old architecture and back up everything
  2. Re-check the command for --data
  3. Verify the backup on disk (tar -t listing or pg_restore --list reads back)
  4. Note the compose project name — it prefixes the volume name (dev-infra_dev-pg-data comes from the dev-infra directory)

Unrelated but in the same neighborhood: local Dockerized databases have another class of pitfall where a silently occupied port makes you connect to the wrong instance — see Two WSL2 + Docker networking traps.

Watch out

  • colima delete --data is irreversible. There is no recycle bin.
  • On colima 0.8.x and earlier, a plain colima delete is equally irreversible.
  • Do not use rm -rf ~/.colima as a "reset" — on the data-disk architecture it equals --data plus losing your configuration.

FAQ​

Does colima delete remove Docker volumes?​

Not since v0.9.0. Container data sits on a dedicated data disk that a plain colima delete leaves untouched — the data comes back on the next colima start. Only colima delete --data wipes that disk, and that is irreversible.

Where does Docker store named volume data on a Mac with colima?​

Inside the colima VM's data disk image: ~/.colima/_lima/_disks/colima/datadisk. On the machine tested here it is a 100 GiB sparse file with an actual usage of about 1.2 GiB, mounted inside the VM at /var/lib/docker. Back up volume contents with tar rather than handling the image file directly.

Why is Docker taking up so much disk space on macOS?​

Separate displayed size from real usage: the datadisk shows 100 GiB but du measures about 1.2 GiB. Clean up with docker system prune, then run colima ssh -- sudo fstrim -a to shrink the sparse file (v0.5.0+ also reclaims unused space on restart). The disk can only grow, never shrink: raise disk in colima.yaml and run colima restart (automatic since v0.5.3).

How do I back up and restore a Docker named volume?​

Pack it with a one-off alpine container: docker run --rm -v VOLUME:/data -v "$PWD":/backup alpine tar czf /backup/vol.tgz -C /data . — swap tar czf for tar xzf to restore. For databases like PostgreSQL prefer a pg_dump logical backup; it is cleaner than copying the data directory and survives version upgrades.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

Claude Code Sandbox Diagnostics Lie? Rerun Outside It

· 6 min read

While debugging a workspace-mcp local service inside Claude Code, curl and lsof both came back looking perfectly "normal" — yet the service stayed unreachable. The later discovery was worse: binaries carrying the quarantine attribute hang forever inside the sandbox, which means every conclusion I'd drawn from sandboxed checks was untrustworthy.

TL;DR​

  • On macOS, the Claude Code sandbox doesn't fail loudly — it silently returns plausible-looking empty results: curl connects to nothing without an error, lsof misses real listeners, and binaries with the quarantine attribute hang forever (0 CPU, no output).
  • When diagnosing local services, negative results inside the sandbox (no listener, no process, hung command) are worthless. Rerun the same batch of commands with dangerouslyDisableSandbox to get conclusions you can trust.

Symptoms: a "clean" debug session, all wrong​

The contradiction: every check "returned normally" yet the service stayed down — the failure had two layers.

Layer one: regular diagnostics went quietly wrong. The workspace-mcp service was unreachable, so I ran the standard checks inside the session: curl 127.0.0.1:8000 showed no error, lsof -iTCP showed nothing unusual. By experience, none of the loud signals — connection refused, no listener — appeared. Every command "returned normally." But the service stayed down. I retried inside the sandbox several times; same result every time.

Layer two surfaced later and cut deeper: while looking into Syncthing, its core binary (carrying the com.apple.quarantine attribute) hung forever when executed inside the sandbox — the process existed, sat at 0 CPU, and printed nothing at all.

Both layers point at the same essence: diagnostic commands inside the sandbox lie. Errors make you alert; plausible negative results make you comfortable — and that's the dangerous form.

Why are Claude Code sandbox diagnostics unreliable on macOS?​

Root cause: the sandbox disguises blocking as normal. It distorts commands in three ways, in increasing order of severity.

Network probes go blind. curl 127.0.0.1:8000 inside the sandbox can't reach the port, but it doesn't throw a connection error either — it "returns normally." What you see is not connection refused but a clean empty result, and the wrong conclusion ("nothing is listening") gets written into your notes without a trace. The same applies to the phrasings "connection refused" or "localhost unreachable" — inside the sandbox, those symptoms get swallowed.

Process enumeration goes blind. lsof -iTCP inside the sandbox cannot see other processes' sockets on the host, so it prints nothing. The port is listening; you just can't see it. "No listener found" does not mean "nothing is listening," and any "the service isn't running" verdict built on it is wrong.

Binary execution hangs. The subtlest one. When you execute a binary carrying the com.apple.quarantine attribute (the Syncthing core), the sandbox policy stacks with the Gatekeeper check and the process stops dead at 0 CPU — no return, no crash, no clue.

The obvious escape hatch is welded shut, too. I tried xattr -dr com.apple.quarantine to strip the attribute; on every app under /Applications it returned EPERM — starting with macOS 27, the system locks the quarantine attribute on installed apps. That routine self-help path no longer exists on current macOS.

Fix: rerun the same commands outside the sandbox​

Conclusion first: on macOS, always verify local-service diagnostics (port listeners, processes, Gatekeeper, unified log, quarantined binaries) outside the sandbox.

Sandbox vs. bypassed diagnostics on macOS: three silent failure modes inside, real results after bypassing

The fix is mechanical — rerun the same batch of commands with dangerouslyDisableSandbox. Side-by-side:

CommandInside the sandboxOutside the sandbox
syncthing --versionhangs forever, 0 CPUreturns in seconds, normal version output
Port checkempty resultreal listener state
Process checkempty resultreal process list
Unified lognot foundfully queryable

Once outside, the earlier "everything looks fine" illusion collapsed — ports, processes and the unified log all came back with real data, and nearly every "negative" check from the first round got overturned.

The rule I now keep: negative results inside the sandbox don't count. This is not "sandbox output is garbage" — positive findings (a listener you did see, a process you did find) remain valid. What's broken is the empty results: they cannot distinguish "genuinely absent" from "the sandbox won't let you see." And sandbox-style guardrails distorting commands is a pattern, not a one-off — Claude Code's Hook interception falsely blocks normal commands the same way; your criteria need to anchor on execution semantics, not surface output.

Boundaries and caveats​

Caveats

  • Bypass for read-only diagnostics: ports, processes, logs and version checks are low-risk; keep everyday builds and execution inside the sandbox — don't bypass globally out of convenience.
  • Untrusted code is the opposite case: the sandbox's isolation value exists precisely for running code you don't trust; that path must not be bypassed.
  • Don't try xattr on macOS 27: it returns EPERM for installed apps, period. Executing outside the sandbox is the faster path.
  • Audit past conclusions: if you previously concluded "service is down" or "port not listening" from sandboxed checks, re-verify them with the sandbox bypassed.

If you're building your own tooling around local MCP services like workspace-mcp, the approach in building a custom MCP toolkit with FastMCP pairs well with this — and when you wrap diagnostic commands as MCP tools, keep the sandbox layer in mind.

FAQ​

curl to 127.0.0.1 inside the Claude Code sandbox shows no error but never connects — is my service down?​

Probably not — the sandbox disguises blocking as clean empty results. On macOS, curl inside the sandbox fails to connect without an error, lsof returns nothing while the port is actually listening, and binaries with the quarantine attribute can hang forever (0 CPU, no message). Bottom line: never trust negative results inside the sandbox; rerun the same commands with dangerouslyDisableSandbox before concluding anything.

What does Claude Code sandbox mode silently block on macOS?​

Three things observed in practice: network probes (curl to localhost fails silently), process enumeration (lsof -iTCP can't see other processes' sockets), and binary execution (a binary with the com.apple.quarantine attribute, like the Syncthing core, hangs at 0 CPU with no error). You can't strip the quarantine attribute either — since macOS 27, xattr -dr returns EPERM for installed apps. These binaries only run outside the sandbox.

How do I safely bypass the Claude Code sandbox for local diagnostics?​

Rerun the same diagnostic commands with dangerouslyDisableSandbox. In my run everything came back real: syncthing --version returned in seconds, and ports, processes and the unified log were all visible. Bottom line: bypass for read-only diagnostics, keep everyday builds and execution inside the sandbox.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

WooCommerce Checkout Template Not Applied? Plugin Override

· 5 min read

After assigning the theme's checkout template to the Checkout page, the front end still renders WooCommerce's own structure — the theme template's heading and footer are nowhere in the output, while the body class reports the assignment as active.

Ran into this while building a minimal FSE WordPress theme for a client — a full-site-editing theme for corporate sites and lightweight e-commerce, with WooCommerce compatibility kept intentionally thin.

TL;DR​

WooCommerce hooks page_template_hierarchy at priority 1 and unshifts its own template slugs (checkout, cart) to the front of the hierarchy array, so the plugin template outranks nearly every candidate. Manually setting _wp_page_template on the page at that point only creates a second, conflicting signal — the body class reads the meta while the render follows the filter. The fix: delete the manually set _wp_page_template and let the hierarchy filter resolve.

Symptom: Body Class Says Theme Template, Render Is the Plugin's​

The template assignment in the page editor clearly names the theme's checkout template, and the body class faithfully shows page-template-checkout; the front-end output, however, is WooCommerce's page-content-wrapper — store notices and product content only, none of the heading and footer structure from the theme template.

The diagnostic marker is a single attribute: check whether the page's <main> element carries data-block-name="woocommerce/page-content-wrapper". If it does, WooCommerce's plugin template is what actually renders — the theme template has been sidelined, confirmed.

A symptom as self-contradictory as "body class says A, render shows B" almost always means two signal sources that never sync — and this machine has exactly one such pair.

Root Cause: page_template_hierarchy Cuts In at Priority 1​

WooCommerce's AbstractPageTemplate registers the filter in init():

add_filter( 'page_template_hierarchy', array( $this, 'page_template_hierarchy' ), 1 );

The callback is a one-line array_unshift: when the page matches the Checkout/Cart scenario, its own template slug goes to the front of the candidate array. The source comments state it plainly — priority 1 is deliberate, to run first; extensions using the default priority 10 line up behind it.

WordPress resolves templates by walking the array and taking the first file that exists. With checkout at the front: if the theme ships a template file of that name, the theme's wins; if not, resolution lands on WooCommerce's registered plugin template of the same slug (page-checkout.html, containing the woocommerce/page-content-wrapper structure).

Why does manually setting _wp_page_template backfire? That meta only feeds the body class and the editor display — it never enters the filter's resolution order. Its signal and the filter's result travel on separate tracks, producing the stalemate "assignment shows active, render doesn't move".

Fix: Delete _wp_page_template and Let the Hierarchy Filter Resolve​

Delete the manually set template meta and let WooCommerce's resolution mechanism run:

wp post meta delete <page_id> _wp_page_template

After deletion, body class and render agree again: whatever the filter resolves is what renders, and the body class reflects it. No template meta should be set explicitly on pages WooCommerce owns — the hierarchy filter is the authoritative signal.

A separate structural pitfall of the Cart template (placeholders and SSR rendering) lives at the same template layer and is worth checking alongside Checkout.

Caution

When verifying the fix, do not set _wp_page_template back "just to test" — that is the very source of the conflicting signal. The Cart page runs the same mechanism; if it shows the same assignment-ignored behavior, treat it identically, diagnosing with the same data-block-name="woocommerce/page-content-wrapper" marker.

FAQ​

How does WooCommerce win template resolution?​

It hooks page_template_hierarchy at priority 1, earlier than consumers at the default priority 10, and unshifts its template slug to the front of the hierarchy array. The WooCommerce source comments state this priority is intentional.

Why do the body class and the actual render disagree?​

Two separate signal sources: the body class is generated directly from the _wp_page_template meta, while the rendered template is decided by the hierarchy filter's array order. A manually set meta falls out of sync with the filter's result.

How do I confirm the plugin template is the one rendering?​

There is exactly one reliable marker: the data-block-name attribute on the main element. data-block-name="woocommerce/page-content-wrapper" means the plugin template renders; a theme-template main is built from the theme's own blocks and carries no such marker.

Is the Cart page taken over the same way?​

Yes. The same AbstractPageTemplate mechanism has two implementations, CartTemplate and CheckoutTemplate, covering both the Cart and Checkout pages — the same data-block-name marker diagnoses them.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

WooCommerce Gallery Images Not Loading? FlexSlider Conflict

· 6 min read

Flipping through the product gallery thumbnails on a WooCommerce product page, everything works until slide seven — from there the main image stays blank, and the DevTools Network panel shows no request was ever sent.

Ran into this while building a minimal FSE WordPress theme for a client — a full-site-editing theme for corporate sites and lightweight e-commerce, with WooCommerce compatibility kept intentionally thin. The issue was ultimately fixed inside the theme with a single filter.

TL;DR​

WordPress 5.5+ automatically injects loading="lazy" into content images, while WooCommerce's FlexSlider gallery moves non-active slides out of the viewport with CSS transforms. Together, the IntersectionObserver that native lazy loading depends on never sees those images enter its trigger range — no request is ever sent. The fix: a wp_get_attachment_image_attributes filter that removes the loading attribute for the woocommerce_single size only.

The first few gallery images render fine; from a certain slide onward the main image area stays blank. The same problem surfaces under searches like "gallery images not showing" or "product images won't load".

DevTools shows three facts at once:

  1. The <img> node exists with a valid src attribute;
  2. The <img> carries loading="lazy";
  3. The Network panel has no matching request — not a failed load, the browser never started the download.

"A src but no request" is the dividing line between this problem and image 404s or broken paths: those show requests and errors, this one is completely silent.

Root Cause: Native Lazy Loading Stacked on Slider Off-Screen Layout​

Every gallery image sits in the state "has a src, not visible, waiting for the browser to decide" — and FlexSlider's layout makes the "visible" condition permanently unreachable. The mechanism has three layers:

Layer 1: WordPress injects lazy loading automatically. Since WordPress 5.5, images output by wp_get_attachment_image() carry loading="lazy" by default (the first image excepted). Product gallery main images use the woocommerce_single size, so all of them match this rule. The intent is bandwidth savings: only load images near the viewport.

Layer 2: FlexSlider moves non-active frames off-screen. FlexSlider arranges all slides in one horizontal strip; slides outside the current frame sit beyond the viewport and swap positions via CSS transforms.

Layer 3: IntersectionObserver's trigger condition is never met. Browser lazy loading is not "load when visible" but "preload when within a threshold" — about 1250px for images on desktop Chrome, expanding to 2500px on slow connections. In a horizontal slider, the distance between slide N and the viewport grows linearly with its index; past the threshold, IntersectionObserver never fires. In practice, from slide seven onward not a single request goes out.

The entire chain throws no error: the img has a src, the page logs no JS exception, the server log is clean — the browser simply classified those images as "not needed yet". That is what makes this expensive to diagnose: each component behaves exactly as documented, and the combination deadlocks.

A wp_get_attachment_image_attributes filter that unsets loading for woocommerce_single images returns gallery images to default eager loading, and the problem disappears.

add_filter(
'wp_get_attachment_image_attributes',
function ( $attr, $attachment, $size ) {
if ( 'woocommerce_single' === $size ) {
unset( $attr['loading'] );
}
return $attr;
},
10,
3
);

Drop it into the theme's functions.php or an inc module; child theme users should put it in the child's functions.php without touching the parent.

Why it works: once the loading attribute is gone, the browser falls back to immediate loading — requests fire during HTML parsing, and FlexSlider's positioning only affects display from then on, never loading. Ordinary content images never pass through a slider, so their lazy loading works and should stay; gallery images have their visibility managed by the slider, so the loading decision goes back to the browser default.

CCLEE Theme ships this filter built in (inc/woocommerce.php) — update the theme and you are covered.

If you are also chasing other WooCommerce block theme rendering issues, gallery problems tend to appear alongside template structure issues, so it is worth reviewing both.

Caution

Do not remove loading globally for convenience — immediate loading for everything below the fold slows the page down, and lazy loading is a pure win for body images. Keep the condition locked to the woocommerce_single size. If you switch sliders (e.g. Swiper), check whether the new slider ships its own lazy-loading module first to avoid stacking two mechanisms.

FAQ​

Why do images with a src attribute never trigger a network request?​

loading="lazy" hands the timing to the browser: when an image sits beyond the preload threshold (about 1250px on desktop Chrome), IntersectionObserver never fires and the request is never sent. A src value only means the DOM is ready — loading depends on the visibility check.

Can I just remove all loading="lazy" attributes site-wide?​

It fixes the gallery, but every image below the fold switches to immediate loading, costing bandwidth and competing with LCP resources. Keep global lazy loading and strip the attribute only for the woocommerce_single size with a filter.

Which slider libraries cause the same problem?​

Any horizontal slider that moves non-active frames out of the viewport: FlexSlider, Swiper, Slick, and similar. If the slider ships its own lazy-loading module (like Swiper's lazy option), use that and remove the native loading attribute to avoid conflicting mechanisms.

Since which WordPress version does this problem exist?​

WordPress 5.5 (2020) introduced native lazy loading, and since 5.9 every content image except the first gets loading="lazy" by default. The problem appears whenever a product gallery uses a translating slider, regardless of WooCommerce or slider version.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

WooCommerce PayPal Buttons Not Showing? Missing form.cart

· 5 min read

Scrolling down to the payment area on a WooCommerce variable product page, the PayPal button spot is completely blank — the container is there, the button is gone, and the browser console shows no error at all.

Ran into this while building CCLEE B2B, a WooCommerce B2B enhancement plugin covering customer group management, tiered pricing, and bulk ordering — and stepped on an undocumented behavior of PayPal Complete Payments (PPCP).

TL;DR​

The first thing PPCP's button script does in init() is document.querySelector("form.cart") — if nothing matches, it returns silently with no log. Customizations like a B2B variation matrix remove the standard add-to-cart form with remove_action, form.cart disappears with it, and PayPal buttons never render again. The fix: wrap the PayPal container in a minimal form.cart, with onsubmit="return false" to block real submissions.

Symptom: Empty PayPal Button Spot, Clean Console​

Everything else on the product page works; the standard add-to-cart button is gone by design, but the PayPal buttons that should appear simply don't render. Searches for "PayPal button not showing" or "PayPal button not rendering" all describe this same situation.

DevTools shows three facts:

  1. The page HTML contains PPCP's button container #ppc-button-ppcp-gateway;
  2. The container is empty — not half-rendered, an empty div;
  3. The console has no errors or warnings, and the ppcp-button script itself loads fine.

"Script loaded, container present, button missing, zero logs" means the problem is not in the network or error layer — it is inside the script's own logic branch.

Root Cause: PPCP's form.cart Precondition Check and Silent Skip​

The ppcp-button script (ppcp-button-js-button.js) starts its init() with document.querySelector("form.cart") — no match, no render, no message. This behavior is absent from PPCP's official documentation; you confirm it by reading the source or comparing against a working product page.

Why would form.cart disappear? WooCommerce's standard add-to-cart form is output by woocommerce_template_single_add_to_cart. B2B variation matrices, quote flows, and price-hiding customizations commonly remove it outright:

remove_action(
'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart',
10
);

That one cut removes more than the add-to-cart button — it also removes the form.cart that PPCP requires before rendering. The custom purchase UI works flawlessly, the page logs nothing — only the PayPal button vanishes.

The silence is what makes this expensive to diagnose: the script reasons "no form, no render target" and quietly exits. You can watch ppcp-button JS download and execute in the Network panel, you can see the button container in the DOM, and not a single line tells you why it chose to do nothing.

Fix: Wrap the PayPal Container in a Minimal form.cart​

Wrap the PayPal container in a minimal form.cart at the spot where it renders, and PPCP's precondition check passes — buttons come back.

add_action( 'woocommerce_single_product_summary', function () {
echo '<form class="cart" onsubmit="return false;">';
echo '<div id="ppc-button-ppcp-gateway" class="ppc-button-wrapper"></div>';
echo '</form>';
}, 25 );

Each part has one job:

  • class="cart" — PPCP checks this class, not an id; keep it verbatim;
  • onsubmit="return false;" — the form is real in the DOM, so a submit triggered by the Enter key or other scripts would reload the page and lose the selected variation; this blocks them all;
  • The container div's id ppc-button-ppcp-gateway is PPCP's convention — match the actual container id on your page.

The full version in CCLEE B2B also fires PPCP's own render action, for reference:

do_action( 'woocommerce_paypal_payments_single_product_button_render' );

If you are deep into customizing WooCommerce templates and purchase flows, the block theme troubleshooting guide covers other common pitfalls at the template layer.

Caution

PPCP is not the only component watching form.cart — third-party add-to-cart enhancers and tracking plugins may listen to it too. After adding the form, walk through a full order in a private window and confirm no script double-fires because of it; do not omit onsubmit="return false", or the Enter key alone will reload the page.

FAQ​

Why does removing the standard add-to-cart form make PayPal buttons disappear?​

The standard form is output by woocommerce_template_single_add_to_cart on the woocommerce_single_product_summary hook at default priority 10. Once remove_action takes it away, the PPCP button script finds no form.cart at init and skips rendering entirely.

How do I quickly confirm the missing form.cart is the cause?​

Check two things: a clean console, and a ppc-button-ppcp-gateway container in the DOM that exists but stays empty. Then temporarily insert an empty <form class="cart"></form> on the product page and reload — if buttons appear, that is the cause.

Can I inject the form.cart with JavaScript on the frontend?​

No. PPCP's init() runs its check once during script initialization; a form inserted afterwards never triggers a re-check. The form.cart must be rendered server-side so it exists before the script runs.

Is onsubmit="return false" required?​

Yes. The wrapper form.cart is a real form — a submit triggered by the Enter key or other scripts reloads the page and loses the selected variation. PPCP's dependency on the form actually submitting is zero; return false blocks every submission path.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

WooCommerce Variable Product Price Not Changing? Parent Only

· 5 min read

Running regular_price updates against a Variable product via WP-CLI completes with a success message and the admin shows the new price — yet the product page and the JSON-LD keep displaying the old one.

Ran into this while building Cross-border Product Listing Assistant — one-click product sourcing with AI-generated descriptions and pricing, published to WooCommerce after review — and stepped on a quiet WooCommerce behavior.

TL;DR​

wp wc product update on a Variable product writes the parent product's meta only — no iteration, no cascade, no hint. The storefront price and the JSON-LD schema both read the variation's _price, while the parent price serves only the admin display, and the wc_product_meta_lookup table keeps the old value too. The fix: list every variation under the parent, then update them one by one with wp wc product_variation update.

Symptom: Command Succeeds, Storefront Price Doesn't Move​

wp wc product update 187 --regular_price="16.00" --user=admin --allow-root
# Success: Updated product 187.

Three observations make up the full picture:

  1. The command returns success, without any warning;
  2. In the admin, the parent product's price field already shows the new value;
  3. The product page, price filters, and JSON-LD structured data all still show the old price.

Searches like "price not updating" or "changed price but storefront unchanged" all describe this path. The confusing part is the success message — it truthfully reports "parent updated", it just never claims the parent is where the storefront price comes from.

Root Cause: The Parent Price Is Admin Display, the Real Price Lives in Variations​

A Variable product's price storage is layered: the parent's regular_price in meta serves the admin edit screen; the product page display, cart calculations, and the JSON-LD schema all read each variation's own _price.

wp wc product update stops exactly at the parent layer — it does not iterate variations, does not cascade, and does not warn. After it writes the parent meta:

  • Every variation's _price is untouched;
  • WooCommerce's performance lookup table wc_product_meta_lookup (created in its class-wc-install.php) also keeps the old value, so read paths going through the lookup table return the old price as well.

Of a three-layer read system, only the least important layer got updated. Nothing along the chain ever says "variations not synced" — which is what makes this expensive to diagnose: every step looks like success.

A cache layer holding stale values and bypassing the normal update chain is not unique to WooCommerce — Yoast SEO's og:image serves an indexable cache string directly, bypassing the attachment API; same-shaped root cause, see Yoast og:image Not Following CDN.

Fix: Update the Variations One by One​

First list every variation under the parent:

wp wc product list --parent=187 --fields=id,sku,regular_price --user=admin --allow-root

Then update them individually (wp wc product_variation update accepts one VID per call):

wp wc product_variation update 187 1201 --regular_price="16.00" --user=admin --allow-root
wp wc product_variation update 187 1202 --regular_price="16.00" --user=admin --allow-root

Updating through the variation endpoint goes through WooCommerce's CRUD: the variation meta and the wc_product_meta_lookup table get synced by WooCommerce itself, so the storefront, JSON-LD, and filters all read one consistent new price. For products with many variations, a loop script handles it — one VID per call.

All commands here run inside a Docker container; see Running WP-CLI in Docker for the containerized setup.

Caution

The wp wc command family requires an authenticated user — never drop --user; and do not take the shortcut of a raw database UPDATE — bypassing CRUD desyncs the wc_product_meta_lookup table from the meta, and the storefront can still read the old price.

FAQ​

Why does the admin show the new price while the storefront keeps the old one?​

Two separate read paths: the parent product's edit screen reads the parent's own meta, while the storefront price and JSON-LD both come from the variation's _price. Updating the parent only refreshes the admin-facing copy; the storefront path never moves.

Can I just UPDATE the _price rows in the database?​

Not recommended. Writing to wp_postmeta directly leaves the wc_product_meta_lookup table out of sync, and some read paths keep returning the old price. Use wp wc product_variation update so WooCommerce's CRUD syncs both stores.

Is there a way to update all variations in bulk?​

wp wc product_variation update accepts one VID per call, so bulk updates need a script loop: list every variation ID with --parent first, then run the update for each.

Do Simple products have this problem too?​

No. Simple products have no variations, so the price wp wc product update writes is the storefront price. The non-cascading update is a structural issue unique to Variable products.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me