Skip to content

Instantly share code, notes, and snippets.

@woogists
woogists / wc-hide-read-more-button-out-of-stock.php
Last active June 8, 2023 16:08
[Theming Snippets] Hide loop read more buttons for out of stock items
/**
* Hide loop read more buttons for out of stock items
*/
if (!function_exists('woocommerce_template_loop_add_to_cart')) {
function woocommerce_template_loop_add_to_cart() {
global $product;
if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;
wc_get_template('loop/add-to-cart.php');
}
}
@woogists
woogists / wc-unhook-remove-emails.php
Last active March 22, 2022 19:09
[General Snippets] Unhook and remove WooCommerce default emails.
/**
* Unhook and remove WooCommerce default emails.
*/
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
/**
* Hooks for sending emails during store events
**/
@woogists
woogists / wc-add-currency-symbol.php
Last active July 7, 2024 14:50
Add a custom currency / symbol
/**
* Custom currency and currency symbol
*/
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'Currency name', 'woocommerce' );
return $currencies;
}
@woogists
woogists / wc-override-checkout-fields.php
Created March 11, 2018 15:11
[Customizing checkout fields using actions and filters] Add new shipping fields to WooCommerce
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['shipping']['shipping_phone'] = array(
'label' => __('Phone', 'woocommerce'),
'placeholder' => _x('Phone', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('form-row-wide'),
@woogists
woogists / wc-override-loop-show-cart-buttons.php
Last active July 9, 2021 09:53
[Frontend Snippets] Override loop template and show quantities next to add to cart buttons.
/**
* Override loop template and show quantities next to add to cart buttons
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
@miguelmota
miguelmota / remove_tuxera.sh
Last active June 28, 2025 15:41
Completely uninstall and remove Tuxera NTFS on MacOS (resets trial version)
sudo rm -rf /Applications/Tuxera\ Disk\ Manager.app
sudo rm -rf /Library/Application\ Support/Tuxera\ NTFS
sudo rm -rf /Library/Filesystems/fusefs_txantfs.fs
@lukecav
lukecav / DNS Prefetch domains
Last active July 14, 2025 05:04
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@yuezk
yuezk / format-detection.html
Created November 10, 2015 09:16
HTML format-detection meta tag
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="date=no">
<meta name="format-detection" content="address=no">
<meta name="format-detection" content="email=no">
@JeroenSormani
JeroenSormani / woocommerce-custom-no-shipping-available-message.php
Last active July 4, 2021 08:44
Add a custom 'No shipping methods available' message
<?php
add_filter( 'woocommerce_no_shipping_available_html', 'my_custom_no_shipping_message' );
add_filter( 'woocommerce_cart_no_shipping_available_html', 'my_custom_no_shipping_message' );
function my_custom_no_shipping_message( $message ) {
return __( 'A minimum of 6 products is required. Add more products to complete your purchase' );
}
If your network connection blocks both outbound TCP ports 25 and 587 but allows outgoing TCP port 465, you need your e-mail server to relay mail through a smarthost using SMTPS. Unfortunately, new versions of Postfix no longer natively support using an SMTPS smarthost. Gather the server name, username, and password for your SMTPS-enabled smarthost, then follow these directions for a quick fix.
In this example, I’m using the Comcast SMTP server as my smarthost — replace smtp.comcast.net:465 with the mail server you wish to use as a smarthost.
Install stunnel and Postfix with sudo apt-get install stunnel mailutils postfix
If you weren’t automatically prompted to configure Postfix, run sudo dpkg-reconfigure postfix to access the configuration wizard. Configure Postfix as a “Satellite system”. You must enter a valid domain name for “System mail name”, so use example.com. For “SMTP relay host”, enter [127.0.0.1]:10465
Enable stunnel automatic startup. Run sudo vim /etc/default/stunnel4 and change ENABLED=0 to EN