Skip to content

Instantly share code, notes, and snippets.

View mikejolley's full-sized avatar

Mike Jolley mikejolley

View GitHub Profile
@mikejolley
mikejolley / functions.php
Created September 21, 2012 19:19 — forked from jameskoster/functions.php
WooCommece - Exclude a category from shop page
<?php
/**
* This code should be added to functions.php of your theme
**/
add_filter( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
@mikejolley
mikejolley / functions.php
Created September 19, 2012 09:29 — forked from jameskoster/functions.php
WooCommerce - Change number of upsells displayed and # of products per row
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display');
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_upsells', 20);
if (!function_exists('woocommerce_output_upsells')) {
function woocommerce_output_upsells() {
woocommerce_upsell_display(3,3); // Display 3 products in rows of 3
}
}
@mikejolley
mikejolley / functions.php
Created August 23, 2012 12:35 — forked from ChromeOrange/functions.php
Move Tabs Around in WooCommerce
<?php
add_action( 'wp' , 'wc_order_tabs' );
function wc_order_tabs() {
// Remove tabs
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10 );
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_attributes_tab', 20 );
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30 );
@mikejolley
mikejolley / gist:2137324
Created March 20, 2012 15:46
Remove WooCommerce CSS from shop page
<?php
add_action( 'wp_enqueue_scripts', 'rcd_exclude_css_from_shop' );
function rcd_exclude_css_from_shop() {
if( is_shop() ) {
wp_dequeue_style('woocommerce_frontend_styles');
}
}
?>
@mikejolley
mikejolley / gist:2044109
Last active April 10, 2024 13:17 — forked from jameskoster/header.php
WooCommerce - Update number of items in cart and total after Ajax
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php