Snippet library
WordPress code snippets, ready to use.
707 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
Exclude Specific Products From All Coupons
Prevents WooCommerce coupons from being valid for a defined list of product IDs, protecting margin on premium or already-discounted items regardless of the coupon's own exclude settings.
Auto Cart Discount Over Spend Threshold
Automatically adds a flat-rate discount fee to the cart when the subtotal reaches or exceeds a configurable spending threshold, incentivising larger orders.
Auto-Apply Coupon via URL Parameter
Reads a coupon code from the ?coupon_code= URL query parameter, stores it in the WooCommerce session, and applies it automatically when the cart or checkout page loads.
Require Account for High-Value Orders
Blocks guest checkout when the cart total meets or exceeds a configurable threshold, prompting the customer to log in or register before placing a high-value order.
Add Custom Terms Checkbox at Checkout
Adds a required Terms and Conditions acceptance checkbox before the Place Order button on the WooCommerce checkout page and validates it server-side.
Remove and Reorder Checkout Fields
Streamlines the WooCommerce checkout form by removing unused fields such as Company and Address Line 2 and adjusting field order via priority values.
Hide Coupon Field on Cart and Checkout
Disables the coupon entry field on both the cart and checkout pages to prevent discount hunting while keeping WooCommerce coupon functionality intact for admin-applied coupons.
Add Buy Now Button to Product Page
Adds a Buy Now button alongside Add to Cart on single product pages; clicking it adds the product to the cart and immediately redirects to checkout, bypassing the cart page.
Redirect to Checkout After Adding to Cart
Redirects customers directly to the checkout page after they add any product to the cart, reducing funnel steps for stores with a single-product or impulse-buy focus.
Add Quantity Selector to Shop Archive
Replaces the single-click Add to Cart link on shop and archive pages with a proper form containing a quantity input for simple in-stock products.
Set Products per Shop Page
Controls how many products are displayed per page on WooCommerce shop and archive pages via the loop_shop_per_page filter.
Hide Out-of-Stock Products From Catalog
Excludes out-of-stock products from shop and archive pages via a meta query, keeping catalog listings clean without disabling stock management.
Change Zero Price to Free Label
Replaces the WooCommerce '$0.00' price display with the word 'Free' for products that have a zero price, giving a more customer-friendly presentation.
Prevent Duplicate Items in Cart
Blocks adding a product to the cart if it is already present, showing a friendly notice and redirecting the customer to the cart instead.
Limit Cart to a Single Item
Prevents customers from adding more than one item to the cart at a time, clearing the existing item when a new product is added.
Set Maximum Quantity per Product
Enforces a store-wide cap on the quantity input for every product in WooCommerce, preventing bulk purchases beyond the configured limit.
Auto-Cancel Unpaid Pending Orders
Cancels pending orders that have not been paid within a configurable number of hours, automatically releasing reserved stock back to inventory.
Auto-Complete Virtual and Downloadable Orders
Automatically moves orders to Completed status after payment when every item in the order is virtual or downloadable, skipping the manual Processing step.
Set the Default Payment Gateway
Pre-selects a specific payment gateway on the checkout page by moving it to the top of the available methods list.
Restrict Payment Gateways by Role
Shows or hides specific payment gateways based on the logged-in user's role, letting you offer invoice or bank-transfer options only to wholesale or trusted accounts.
Restrict Payment Gateways by Cart Total
Hides specified payment gateways when the cart subtotal falls below a configurable minimum, useful for bank-transfer or invoice methods that are only practical on larger orders.
Restrict Shipping Methods by Role
Limits available shipping methods based on the current user's role so different customer segments see only the shipping options relevant to them.
Hide Other Shipping When Free Available
Removes all non-free shipping methods from the package rates when at least one free-shipping method is available, keeping checkout focused on the free option.
Lazy YouTube Facade Click-to-Load
Replaces YouTube embeds with a lightweight thumbnail facade and play button; the actual iframe is only inserted after the user clicks, deferring the heavy YouTube scripts.