Skip to content

Add WooCommerce integration and extensibility filters#37

Draft
ilicfilip wants to merge 2 commits intomainfrom
filip/woocommerce-support
Draft

Add WooCommerce integration and extensibility filters#37
ilicfilip wants to merge 2 commits intomainfrom
filip/woocommerce-support

Conversation

@ilicfilip
Copy link
Copy Markdown
Contributor

Summary

  • Adds a WooCommerce integration that exposes products at .md URLs with price, SKU, stock status, attributes, and variations — fixes WooCommerce Product Pages #32.
  • Introduces markdown_alternate_frontmatter and markdown_alternate_content_sections filters so any plugin can extend the markdown output without subclassing. The WooCommerce integration is the reference implementation.
  • Adds markdown_alternate_cache_version filter and mixes it into the transient cache key, so integrations pulling from postmeta can invalidate cleanly. Woo also invalidates on woocommerce_update_product and stock-change hooks.

Design notes

  • ContentRenderer::generate_frontmatter() now builds an associative data array and passes it through a YAML serializer, so integrations add keys instead of string-munging YAML.
  • Body sections are a priority-ordered list (title=0, post_content=100). Integrations can interleave — e.g. Woo places a summary at 10, short description at 50, attributes at 150, variations at 160.
  • Woo integration is guarded by class_exists('WooCommerce') in Plugin::register_integrations().

Test plan

  • With WooCommerce active, /product/sample.md returns a product page with price/SKU/stock in frontmatter and a summary block in the body
  • Variable product renders a ## Variations section listing each variation with attributes + price
  • Simple product with no attributes renders without an empty ## Attributes heading
  • Updating a product's price invalidates the cached .md output
  • Without WooCommerce active, posts and pages still render unchanged
  • A third-party filter adding a cook_time frontmatter key and an "Ingredients" section renders correctly

Exposes WooCommerce products at .md URLs with price, SKU, stock,
attributes, and variations. Introduces two filters
(markdown_alternate_frontmatter, markdown_alternate_content_sections)
plus a cache_version filter so any plugin can extend the markdown
output without subclassing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>
get_price_html() injects screen-reader spans and NBSP entities that
look garbled in markdown. Build the price from raw values via wc_price()
instead, and decode entities/NBSP for clean output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WooCommerce Product Pages

1 participant