Write theme file
ps_write_theme_file
Changes a file of your shop's look, with a backup made first.
Ask Claude
„Add a line "Free delivery over 250 PLN" under the price on the product page.”
Example preview
templates/catalog/_partials/product-prices.tpl
@@ line 88 @@
{/block}
+ <p class="free-delivery">{l s='Free delivery over 250 PLN' d='Shop.Theme.Catalog'}</p>
Smarty validation: OK. New scripts: none. Backup will be created before saving.Technical details
Changes a file of the ACTIVE theme (.tpl, .css, .js, .json): replaces a fragment (search -> replace; the fragment must appear exactly once) or writes the whole content (content, also a new file such as assets/css/custom.css). Before saving: validation (Smarty: allowed tags and modifiers only, plus compilation; JSON: syntax), warnings about new scripts and external domains, automatic backup. For module template overrides use ps_override_module_template. Service connector only (allowlisted IP addresses).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| path | string | yes | Path in the active theme, for example templates/catalog/product.tpl (max 300). |
| search | string | no | Exact fragment to replace, with whitespace as in the file (max 100,000). Must appear exactly once. |
| replace | string | no | New fragment, with search (max 100,000). |
| content | string | no | Whole new file content instead of search/replace (max 500,000). |
| confirm | boolean | no | false (default) returns a preview and saves nothing. true executes, only after the user approved the preview, together with change_token. |
| change_token | string | when: confirm=true | Token from the preview. Required with confirm=true. Valid 30 minutes, single use, bound to the previewed arguments and data state. |
Limits
20 file writes per hour. Active theme only; the parent theme is read-only. Extensions .tpl, .css, .js, .json. After saving: ps_clear_cache and ps_inspect_page.
What you see before anything is saved
Claude first calls the tool without confirming it. The module returns a preview (current and new values) and a single-use token valid for 30 minutes. Claude shows you the preview and saves the change only after your yes.
Related tools
- Read theme file ps_read_theme_file
- List file backups ps_list_file_backups
- Restore file backup ps_restore_file_backup
- Clear cache ps_clear_cache
- Inspect a store page ps_inspect_page
Last updated: 2026-10-03