ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Woo​Commerce

by renzojohnson ST3 New

WooCommerce snippets and completions for Sublime Text. 172 curated code patterns for hooks, CRUD, REST API, HPOS, checkout, and more. Built from WooCommerce 10.x source.

Details

Installs

  • Total 0
  • Win 0
  • Mac 0
  • Linux 0
Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9 Feb 8 Feb 7 Feb 6 Feb 5
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

WooCommerce — Sublime Text Snippets

Package Control WooCommerce Sublime Text License: MIT

The only WooCommerce snippet package with HPOS, Block Checkout, Store API, and Action Scheduler patterns.

172 curated code recipes for WooCommerce development in Sublime Text. Built from the WooCommerce 10.5.2 source — not a dictionary dump of function signatures. Every snippet expands to a complete, working code pattern with intelligent tab stops.


Why This Package?

Every other WooCommerce snippet package on Package Control is frozen at WooCommerce 3.x (2017). In the 8 years since:

  • HPOS replaced the wp_posts table for order storage (mandatory since WC 9.0)
  • Block Checkout replaced the shortcode checkout (actively deprecated)
  • Store API replaced the legacy frontend API
  • Action Scheduler replaced WP Cron for background processing
  • REST API v3 is the standard for integrations
  • Hundreds of new hooks, filters, and API methods were added

This package covers all of it. The dead packages don't.

Curated Recipes, Not Dictionary Dumps

The abandoned “WooCommerce Autocomplete” package has 3,393 flat completions — every function, hook, and constant dumped into one file. It's unusable noise.

This package has 172 curated snippets. Each one is a real code pattern: a complete add_action() call with the correct callback signature, a full payment gateway scaffold, an HPOS-compatible order query with real parameters. Think recipe, not dictionary entry.


Quick Start

  1. Install via Package Control: Cmd+Shift+PPackage Control: Install PackageWooCommerce
  2. Open any PHP file
  3. Type wc: and browse the autocomplete menu
  4. Select a snippet and press Tab
  5. Use Tab to jump between placeholders

All triggers start with wc: — type it and see every available pattern organized by category.


What's Included

Category Count Prefix Description
Action Hooks 32 wc:action: add_action() with correct signatures
Filter Hooks 32 wc:filter: add_filter() with return values
CRUD 15 wc:get: wc:create: wc:update: Orders, products, customers, coupons
Queries 10 wc:query: wc_get_orders(), WC_Product_Query, meta queries
Cart 8 wc:cart: Items, totals, fees, sessions, coupons
Checkout 8 wc:checkout: Fields, validation, gateways, redirects
REST API 8 wc:rest: Endpoints, schemas, webhooks
Conditionals 12 wc:is: is_shop(), is_product(), is_checkout()
Admin 8 wc:admin: Settings pages, product tabs, meta boxes
Emails 5 wc:email: Custom email class, triggers, templates
HPOS 6 wc:hpos: Modern order storage patterns
Templates 6 wc:template: Overrides, hooks, template parts
Shipping 6 wc:shipping: Custom methods, zones, rates
Action Scheduler 4 wc:scheduler: Background tasks, recurring jobs
Blocks / Store API 5 wc:blocks: Block checkout, Store API extensions
Notices 5 wc:notice: wc:log: Frontend notices, WC logger
Security 4 wc:nonce: wc:cap: wc:sanitize: Nonces, capabilities, validation
Total 172

Full Trigger Reference

Action Hooks

Trigger Description
wc:action:init Hook into WooCommerce init
wc:action:loaded Hook after WooCommerce loads
wc:action:register_taxonomy After WC taxonomies register
wc:action:register_post_type After WC post types register
wc:action:add_to_cart After item added to cart
wc:action:cart_updated After cart quantities update
wc:action:before_calculate_totals Before cart totals calculate
wc:action:check_cart_items Validate cart contents
wc:action:cart_emptied After cart is emptied
wc:action:checkout_process Validate during checkout submit
wc:action:checkout_order_processed After checkout creates order
wc:action:checkout_create_order During order creation
wc:action:checkout_update_order_meta Save custom checkout data
wc:action:payment_complete After payment completes
wc:action:thankyou Thank you page content
wc:action:new_order When new order is created
wc:action:order_status_changed When order status changes
wc:action:order_status Specific order status transition
wc:action:order_refunded When order is refunded
wc:action:before_single_product Before single product page
wc:action:after_single_product After single product page
wc:action:before_shop_loop Before product archive loop
wc:action:after_shop_loop After product archive loop
wc:action:before_shop_loop_item Before each product in loop
wc:action:after_shop_loop_item After each product in loop
wc:action:single_product_summary Single product summary area
wc:action:process_product_object Admin product save (modern)
wc:action:process_product_meta Admin product save (legacy)
wc:action:update_options After WC settings saved
wc:action:before_cart Before cart page content
wc:wrap:action Wrap selection in add_action
wc:wrap:filter Wrap selection in add_filter

Filter Hooks

Trigger Description
wc:filter:price Modify product price
wc:filter:regular_price Modify regular price
wc:filter:sale_price Modify sale price
wc:filter:price_html Modify price HTML display
wc:filter:cart_item_price Modify cart item price display
wc:filter:add_to_cart_validation Validate add to cart
wc:filter:cart_item_quantity Modify cart quantity input
wc:filter:cart_item_name Modify cart item name
wc:filter:cart_item_thumbnail Modify cart item thumbnail
wc:filter:calculated_total Modify cart calculated total
wc:filter:checkout_fields Modify all checkout fields
wc:filter:billing_fields Modify billing fields
wc:filter:shipping_fields Modify shipping fields
wc:filter:default_address_fields Modify default address fields
wc:filter:payment_complete_status Change status after payment
wc:filter:available_gateways Filter payment gateways
wc:filter:product_tabs Add/remove product tabs
wc:filter:add_to_cart_text Change add to cart button text
wc:filter:add_to_cart_url Change add to cart URL
wc:filter:short_description Modify product short description
wc:filter:product_visible Control product visibility
wc:filter:product_data_tabs Admin product data tabs
wc:filter:order_number Modify displayed order number
wc:filter:order_item_name Modify order item name
wc:filter:email_headers Modify email headers
wc:filter:email_attachments Add email attachments
wc:filter:email_recipient Modify email recipient
wc:filter:locate_template Override template location
wc:filter:currency Change store currency
wc:filter:countries Filter allowed countries

CRUD

Trigger Description
wc:get:order Get order by ID
wc:get:orders Query multiple orders
wc:get:product Get product by ID
wc:get:products Query multiple products
wc:get:customer Get customer by user ID
wc:create:order Create order programmatically
wc:create:product Create simple product
wc:update:order_meta Update order meta data
wc:update:product_meta Update product meta data
wc:order:note Add note to order
wc:order:status Update order status
wc:order:items Loop through order items
wc:product:variations Get product variations
wc:coupon:create Create coupon programmatically
wc:refund:create Create refund for order

Queries

Trigger Description
wc:query:orders Advanced order query
wc:query:products Advanced product query
wc:query:product_query WC_Product_Query object
wc:query:order_query WC_Order_Query object
wc:query:customers Query WooCommerce customers
wc:query:subscriptions Query WC Subscriptions
wc:query:coupons Query coupons
wc:query:categories Query product categories
wc:query:by_meta Products by custom meta
wc:query:by_date Orders by date range

Cart

Trigger Description
wc:cart:add Add item to cart
wc:cart:items Loop through cart items
wc:cart:total Get cart totals
wc:cart:empty Empty the cart
wc:cart:coupon Apply coupon to cart
wc:cart:fee Add custom fee to cart
wc:cart:session Get/set cart session data
wc:cart:shipping Get chosen shipping method

Checkout

Trigger Description
wc:checkout:field Add custom checkout field
wc:checkout:validate Validate checkout field
wc:checkout:save Save checkout field to order
wc:checkout:remove_field Remove checkout field
wc:checkout:reorder Reorder checkout fields
wc:checkout:gateway Payment gateway scaffold
wc:checkout:redirect Custom thank you redirect
wc:checkout:order_review Modify order review

REST API

Trigger Description
wc:rest:endpoint Custom REST endpoint scaffold
wc:rest:get GET endpoint with parameters
wc:rest:post POST endpoint with validation
wc:rest:extend Extend WC REST response
wc:rest:auth REST authentication check
wc:rest:schema REST schema definition
wc:rest:request Internal WC REST request
wc:rest:webhook Register custom webhook topic

Conditionals

Trigger Description
wc:is:shop Check if shop page
wc:is:product Check if single product
wc:is:cart Check if cart page
wc:is:checkout Check if checkout page
wc:is:account Check if account page
wc:is:woocommerce Check if any WC page
wc:is:category Check if product category
wc:is:tag Check if product tag
wc:is:order_received Check if thank you page
wc:is:ajax Check if WC AJAX request
wc:is:rest Check if WC REST request
wc:is:hpos Check if HPOS is enabled

Admin

Trigger Description
wc:admin:settings_page WC settings page scaffold
wc:admin:settings_field Add WC settings field
wc:admin:product_tab Custom product data tab
wc:admin:product_panel Product options panel fields
wc:admin:order_meta_box Order edit meta box
wc:admin:column Custom orders list column
wc:admin:bulk_action Orders bulk action
wc:admin:notice WC-style admin notice

Emails

Trigger Description
wc:email:class Custom email class scaffold
wc:email:trigger Trigger WC email
wc:email:content Email body with template
wc:email:register Register email with WC
wc:email:template Override email template

HPOS

Trigger Description
wc:hpos:order HPOS-safe order retrieval
wc:hpos:meta HPOS-safe order meta
wc:hpos:query HPOS-compatible order query
wc:hpos:declare Declare HPOS compatibility
wc:hpos:check Check if HPOS is active
wc:hpos:custom_table Extend HPOS custom tables

Templates

Trigger Description
wc:template:override Override WC template in theme
wc:template:before Add content before template
wc:template:after Add content after template
wc:template:remove Remove template hook callback
wc:template:part Load WC template part
wc:template:locate Locate template with custom path

Shipping

Trigger Description
wc:shipping:method Shipping method class scaffold
wc:shipping:calculate Calculate shipping rates
wc:shipping:zone Get shipping zones
wc:shipping:free Free shipping threshold
wc:shipping:hide Hide shipping methods conditionally
wc:shipping:register Register shipping method

Action Scheduler

Trigger Description
wc:scheduler:single Schedule single action
wc:scheduler:recurring Schedule recurring action
wc:scheduler:callback Action callback handler
wc:scheduler:search Search scheduled actions

Blocks / Store API

Trigger Description
wc:blocks:extend Extend Store API schema
wc:blocks:checkout_field Block checkout custom field
wc:blocks:inner_block Register checkout inner block
wc:blocks:integration Register block integration
wc:blocks:store_api Custom Store API endpoint

Notices

Trigger Description
wc:notice:error Add error notice
wc:notice:success Add success notice
wc:notice:info Add info notice
wc:log:error Log error to WC logger
wc:log:info Log info to WC logger

Security

Trigger Description
wc:nonce:verify WC nonce verification
wc:cap:check WooCommerce capability check
wc:sanitize:order Sanitize order data
wc:validate:product Validate product data

How Snippets Work

All triggers use the wc: prefix with colon-separated categories:

wc:{category}:{name}
  1. Open a PHP file in Sublime Text
  2. Type wc: — the autocomplete panel shows all available snippets
  3. Continue typing to filter: wc:checkout: narrows to checkout patterns
  4. Press Tab or Enter to expand
  5. The snippet expands with pre-filled defaults and tab stops
  6. Press Tab to jump to the next placeholder
  7. Edit only what you need — defaults are immediately usable

Tab Stop Design

Every snippet follows these conventions:

  • $1 — The value you'll most likely change (hook name, field name, etc.)
  • $2$n — Parameters in order of importance
  • $0 — Final cursor position after all tabs
  • All stops use ${n:default} — snippets work without editing a single placeholder

Wrap Snippets

Two special snippets use $SELECTION to wrap highlighted code:

  • wc:wrap:action — Wrap selected code in add_action()
  • wc:wrap:filter — Wrap selected code in add_filter()

Select code, then trigger the snippet via the Command Palette.


Installation

Package Control (Recommended)

  1. Open Command Palette: Cmd+Shift+P (Mac) / Ctrl+Shift+P (Windows/Linux)
  2. Type Package Control: Install Package
  3. Search for WooCommerce
  4. Press Enter to install

Manual Installation

  1. Download the latest release
  2. Extract to your Sublime Text Packages directory:
    • Mac: ~/Library/Application Support/Sublime Text/Packages/
    • Windows: %APPDATA%\Sublime Text\Packages\
    • Linux: ~/.config/sublime-text/Packages/

Git Clone

cd ~/Library/Application\ Support/Sublime\ Text/Packages/
git clone https://github.com/renzojohnson/woocommerce.git WooCommerce

WooCommerce Compatibility

Package Version WooCommerce Version PHP Version
1.0.0 10.5.2 7.4+

All snippets are built from and tested against WooCommerce 10.5.2 source code. Patterns use the modern WC_Data API, HPOS-compatible methods, and current best practices. Legacy patterns (like update_post_meta for orders) are intentionally excluded.


Works With

These snippets are designed to work alongside:

  • WooCommerce Blocks — Block checkout field registration, Store API extensions
  • WooCommerce Subscriptions — Subscription query patterns included
  • Action Scheduler — Background job scheduling and management
  • WooCommerce REST API v3 — Endpoint scaffolds and schema definitions
  • HPOS (Custom Order Tables) — All order operations use HPOS-safe methods

Troubleshooting

Snippets don't expand when I press Tab:

Check that : is not in your word_separators setting. Open Preferences → Settings and verify word_separators does not include :.

Snippets show in HTML but not in PHP:

Snippets are scoped to source.php. They only trigger inside <?php ?> blocks, not in HTML regions of PHP files.

I see old completions from another package:

If you have the abandoned “WooCommerce Autocomplete” package installed, remove it first. It conflicts with trigger names.


Contributing

Contributions are welcome. To add or improve a snippet:

  1. Fork the repository
  2. Create a branch: git checkout -b feature/new-snippet
  3. Add your .sublime-snippet file to the appropriate snippets/ subdirectory
  4. Follow the naming convention: {category}-{name}.sublime-snippet
  5. Ensure all PHP $ variables are escaped as \$ in the CDATA section
  6. Include $0 as the final cursor position
  7. Submit a pull request

Snippet Conventions

  • Trigger format: wc:{category}:{name} (max 3 levels)
  • Scope: source.php for all snippets
  • Description: 40 characters max, action-oriented
  • Tab stops: $1 = most likely to change, $0 = final cursor
  • All stops use ${n:default} — never bare $n

Author

Renzo Johnsonrenzojohnson.com · Contact


License

MIT


WooCommerce is a registered trademark of Automattic Inc. This package provides development tooling and is not affiliated with or endorsed by Automattic.