Coding Snippets
Copy-ready PHP snippets for WooCommerce and WordPress, with notes on where to add them and what each hook does.
How to Add Custom PHP Code in WordPress (Without Breaking Your Site)
Quick answer: The safest way to add custom PHP to WordPress is a code snippets plugin, because the code survives theme updates and a…
WooCommerce Cart Fees with PHP: woocommerce_cart_calculate_fees Hook + Examples
Quick answer: Hook a function to woocommerce_cart_calculate_fees and call $cart->add_fee( 'Label', $amount, $taxable ) inside it. WooCommerce runs the hook every time it recalculates…
Insert Standard Text in All WordPress Posts Automatically
Quick answer: To show the same content under every post, hook a function to the the_content filter that appends your HTML when is_single() is…
How to Customize the WooCommerce Add to Cart Button (Text, Color, Style & Position)
Quick answer: To change the Add to Cart button text, use the woocommerce_product_single_add_to_cart_text filter (single product pages) and woocommerce_product_add_to_cart_text (shop pages), or set labels…
How to Hide WooCommerce Products by User Role Using PHP Snippets
Quick answer: To hide a product from certain roles, return false from the woocommerce_product_is_visible filter when the current user has that role. To keep…
Get WooCommerce Product Price by ID (PHP): get_price(), get_regular_price() & get_sale_price()
Quick answer: Load the product with wc_get_product( $product_id ), then call get_price() for the current price, get_regular_price() or get_sale_price() for the individual prices, or…
The plugins behind most of what we write about.
A lot of the posts here reference WPFactory plugins because that's what we build with. All Access gets you every plugin we make, on as many sites as you run. Pay once. Own it.
- Every WPFactory plugin, current and future
- Unlimited sites, no per-site caps
- Lifetime updates, no renewals
- 30-day refund, no questions asked