Skip to content

Instantly share code, notes, and snippets.

View conschneider's full-sized avatar
🐼
Relax. Nothing is under control.

Con Schneider conschneider

🐼
Relax. Nothing is under control.
View GitHub Profile
@jameskoster
jameskoster / functions.php
Created January 12, 2012 16:58
WooCommerce - Change number of products per row
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
@jameskoster
jameskoster / functions.php
Last active November 21, 2023 11:32
WooCommerce - change number of products displayed per page
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}
@jameskoster
jameskoster / functions.php
Last active July 3, 2018 14:19
WooCommerce - set image dimensions upon theme activation
<?php
/**
* Hook in on activation
*/
/**
* Define image sizes
*/
function yourtheme_woocommerce_image_dimensions() {
global $pagenow;
@jameskoster
jameskoster / functions.php
Last active September 30, 2015 19:48
WooCommerce - Allow shortcodes in product excerpts
if (!function_exists('woocommerce_template_single_excerpt')) {
function woocommerce_template_single_excerpt( $post ) {
global $post;
if ($post->post_excerpt) echo '<div itemprop="description">' . do_shortcode(wpautop(wptexturize($post->post_excerpt))) . '</div>';
}
}
@mikejolley
mikejolley / gist:1926284
Last active June 8, 2020 17:24
WooCommerce - Change WooCommerce email subject lines
/*
* goes in theme functions.php or a custom plugin
*
* Subject filters:
* woocommerce_email_subject_new_order
* woocommerce_email_subject_customer_processing_order
* woocommerce_email_subject_customer_completed_order
* woocommerce_email_subject_customer_invoice
* woocommerce_email_subject_customer_note
* woocommerce_email_subject_low_stock
@mikejolley
mikejolley / gist:2263203
Last active June 1, 2019 17:50
WooCommerce - Add custom field (in an order) to the order emails
/**
* Add the field to order emails
**/
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');
function my_woocommerce_email_order_meta_keys( $keys ) {
$keys['How did you hear about us?'] = 'hear_about_us';
return $keys;
}
@jameskoster
jameskoster / functions.php
Created June 6, 2012 10:35
WooCommerce - Change number of thumbnails per row in product galleries
add_filter ( 'woocommerce_product_thumbnails_columns', 'xx_thumb_cols' );
function xx_thumb_cols() {
return 4; // .last class applied to every 4th thumbnail
}
@mikejolley
mikejolley / gist:3097073
Last active January 18, 2024 17:54
WooCommerce - Unhook/Disable emails
/**
* Code goes in functions.php or a custom plugin.
*/
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
/**
* Hooks for sending emails during store events
**/
@spivurno
spivurno / gw-gravity-forms-email-domain-validator.php
Last active September 16, 2021 13:05
Gravity Wiz // Gravity Forms // Email Domain Validator // Ban/Limit Email Domains for Gravity Form Email Fields
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-email-domain-validator.php
*/
/**
* Gravity Wiz // Gravity Forms // Email Domain Validator
*
* This snippets allows you to exclude a list of invalid domains or include a list of valid domains for your Gravity Form Email fields.
<?php
/**
* In theory should support the following subdir sites as port of a subdomain network:
* - subdomain.example.org/site1
* - subdomain.example.org/site2
*/
function can_i_haz_subdomain_and_subdir() {
global $wpdb, $current_blog, $current_site, $blog_id, $site_id;
// Taken from ms-settings.php