Skip to content

Instantly share code, notes, and snippets.

View stuartduff's full-sized avatar

Stuart Duff stuartduff

View GitHub Profile
@stuartduff
stuartduff / remove-storefront-handheld-footer-links.php
Last active April 3, 2018 12:42
Remove the WooCommerce Storefront theme handlheld footer bar links
@stuartduff
stuartduff / gist:075bcb18d7ee836f17c86dc341e3340b
Created April 3, 2018 12:34
Remove cart from storefront mobile sticky footer
add_filter( 'storefront_handheld_footer_bar_links', 'remove_mobile_links' );
function remove_mobile_links( $links ) {
unset( $links['cart'] );
return $links;
}
@stuartduff
stuartduff / wc-set-single-product-image-cropping-sizes.php
Last active April 3, 2018 10:32
Set cropping sizes for WooCommerce single product images.
add_filter( 'woocommerce_get_image_size_single', 'custom_wc_product_img_size' );
add_filter( 'woocommerce_get_image_size_shop_single', 'custom_wc_product_img_size' );
add_filter( 'woocommerce_get_image_size_woocommerce_single', 'custom_wc_product_img_size' );
function custom_wc_product_img_size() {
$size = array(
'width' => 800,
'height' => 800,
'crop' => 1,
);
@stuartduff
stuartduff / wc-set-image-sizes.php
Last active February 16, 2018 11:42
WooCommerce set images sizes
add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 300,
'single_image_width' => 600,
) );
@stuartduff
stuartduff / remove-wocommerce-product-quantity-fields.php
Created October 11, 2016 12:02
Remove WooCommerce product quantity fields
/**
* @desc Remove in all product type quanityt fields
*/
function wc_remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
@stuartduff
stuartduff / remove-woocommerce-product-sales-badge.php
Created February 7, 2017 14:44
Remove the WooCommerce sales badge from products using a filter
function sd_custom_hide_sales_flash() {
return false;
}
add_filter( 'woocommerce_sale_flash', 'sd_custom_hide_sales_flash' );
@stuartduff
stuartduff / wc-custom-login-redirect.php
Last active January 5, 2018 17:23
This will redirect the customer the referring url on login to WooCommerce.
function wc_custom_login_redirect() {
// This will redirect the customer the referring url on login to WooCommerce..
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect($location);
exit();
}
add_filter('woocommerce_login_redirect', 'wc_custom_login_redirect');
@stuartduff
stuartduff / sf-add-text-after-featured-products
Created October 9, 2017 13:33
Storefront add text to after featured products area
@stuartduff
stuartduff / change-products-per-page-storefront.php
Created October 9, 2017 14:59
Change WooCommerce products per page in Storefront
function alter_sf_products_per_page() {
// Return the number of products per page ( default: 12 ).
return 8;
}
add_filter('storefront_products_per_page', 'alter_sf_products_per_page' );
<img src="%clipboard" />