25% off ProSNIPC25OFF

Snippet library

PHP snippets for WordPress.

467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.

PHP

Change Cart and Checkout Thumbnail Size

Overrides the WooCommerce cart and checkout line-item product thumbnail dimensions to a custom width and height.

#cart#customization#images
PHP

Move Shop Category Description Below Products

Removes the WooCommerce archive description from above the product grid and re-inserts it below the loop so products appear first.

#archive#frontend#layout
PHPPro

Redirect to a Custom Page After Checkout

Sends customers to a custom thank-you or upsell page after completing a WooCommerce order instead of the default order-received endpoint.

#checkout#conversion#orders
PHPPro

Require Purchase to Leave a Product Review

Restricts WooCommerce product reviews to verified buyers only — the review form is hidden and the comment is blocked for non-purchasers.

#customers#reviews#security
PHPPro

Set Out-of-Stock Products to Draft Automatically

Watches WooCommerce stock updates and automatically switches any product to Draft status the moment its stock quantity reaches zero.

#automation#inventory#products
PHP

Sort Out-of-Stock Products Last in Catalog

Pushes out-of-stock WooCommerce products to the end of shop and archive loops while preserving the existing sort order for in-stock items.

#catalog#products#sorting
PHP

Show Amount Saved on Sale Products

Appends a 'You save $X (Y%)' message after the price on WooCommerce sale products, showing both the absolute and percentage discount.

#display#frontend#pricing
PHP

Hide Sale Badges Across the Store

Removes the 'Sale!' flash badge from all WooCommerce product cards and single product pages by returning an empty string.

#badges#display#frontend
PHP

Set Minimum Order Quantity per Product

Reads a per-product minimum quantity meta value and enforces it on the quantity input and at add-to-cart validation.

#cart#products#quantity
PHPPro

Enforce Minimum and Maximum Product Price

Validates a WooCommerce product's regular price against configurable min/max bounds on admin save and surfaces an error notice if violated.

#admin#pricing#products
PHP

Change WooCommerce Currency Symbol or Format

Overrides the WooCommerce currency symbol, price display format, decimal separator, and thousands separator via filters.

#currency#formatting#localization
PHPPro

Replace Add to Cart with a Call-to-Order Button

Disables the add-to-cart button on opted-in products and replaces it with a phone or enquiry CTA drawn from product meta.

#checkout#cta#customization
PHPPro

Change a User's Role After Purchase

Automatically upgrades or assigns a WordPress role to a customer when they complete an order containing a specific product.

#automation#customers#orders
PHPPro

Prevent Repeat Purchase of a Product

Blocks customers from adding or purchasing a product they have already bought in a completed or processing order.

#checkout#customers#orders
PHP

Add Total Word Count to the Publish Box

Displays the post's word count inside the Classic Editor's Publish meta box and keeps it updated live in the Block Editor.

#admin#content#editor
PHPPro

Strip the Admin Bar to Essential Items

Removes all non-essential admin bar nodes for non-administrator users, leaving only the site name and user account links.

#access-control#admin#admin-bar
PHP

Sort Admin Post List Alphabetically by Title

Sets the default ordering of the Posts list table in wp-admin to A-Z by title when no custom sort column is active.

#admin#list-table#posts
PHPPro

Enqueue a Custom Admin Stylesheet

Loads a custom CSS file from the active theme into every wp-admin screen, allowing targeted overrides of WordPress admin styles.

#admin#branding#css
PHP

Disable Email Domain Typo Suggestion

Dequeues the mailcheck library used by WooCommerce and WPForms to suppress the 'Did you mean …?' email-domain correction prompt.

#admin#email#forms
PHPPro

Post Meta Debug Panel for Admins

Adds a meta box to all public post type edit screens that dumps every piece of post meta, visible to administrators only.

#admin#debug#developer
PHP

Time-Based Greeting in the Admin Bar

Displays a personalised Good morning/afternoon/evening greeting with the current user's display name in the WordPress admin bar.

#admin#admin-bar#dashboard
PHP

Collapse the Admin Menu by Default

Sets the admin sidebar to start in its collapsed state for users who have not yet expressed a preference.

#admin#dashboard#menu
PHPPro

Show Staging/Environment Banner in Admin Bar

Adds a coloured environment label (Staging, Development, Local) to the admin bar so users always know they are not on production.

#admin#admin-bar#environment
PHPPro

Hide Specific User Roles from the Role Selector

Prevents non-administrator users from assigning powerful roles such as Administrator or Editor when editing a user's profile.

#access-control#admin#roles