Category archive / snippet / page 2
Snippet articles.
Page 2 of snippet articles, guides, and code snippets by Bonny Elangbam.
← First archive pageSnippet notes
How to Add a Custom Required Field to WooCommerce Checkout (and Save to Order Meta & Emails)
Add, validate, save, display, and email a required WooCommerce checkout field without installing another checkout-field plugin.
Programmatically Apply an Auto-Discount Based on Cart Item Count or User Role
Apply a WooCommerce cart discount automatically when a customer buys enough items or belongs to a specific WordPress role.
Automatically Change WooCommerce Orders to Completed for Virtual and Digital Products
Move paid WooCommerce orders to Completed automatically when every purchased item is virtual and downloadable.
Disable WooCommerce Cart Fragments AJAX on Non-eCommerce Pages
Stop the cart fragments request on posts and other non-commerce pages for a lighter WooCommerce frontend and a potential 100–300ms speed improvement.
Disable WooCommerce Scripts and Styles on Non-Shop and Blog Pages
Conditionally remove WooCommerce frontend assets from pages that do not use products, checkout, cart, or account features.
A safer WordPress hook for body classes
Add a useful context class to the body element without coupling your theme to a page template.
WooCommerce's default variation dropdowns into selectable radio buttons
Replace WooCommerce variation dropdowns with selectable radio-button pills while keeping the native selects and variation logic intact.
Disable XML-RPC in WordPress (Crucial Security Fix)
Disable the legacy WordPress XML-RPC API without a plugin when your site does not use the mobile app or Jetpack, reducing an unnecessary brute-force and pingback attack surface.
Display In Stock or Out of Stock Status on WooCommerce Product Pages
Show a tailored In Stock or Out of Stock message on WooCommerce product pages using the product's real stock status.
Disable Flat Rate When Free Shipping Is Available in WooCommerce
Hide WooCommerce flat-rate methods whenever a free-shipping method is available in the current package.