Skip to content

Instantly share code, notes, and snippets.

@simonlk
simonlk / Woocommerce - list of available product variations
Created October 28, 2012 04:53
Output Woocommerce product variations as a table so they look like a single product
<?php
// Output variations as a list so they look like a single product
// Works in theme/woocommerce/single-product/add-to-car/variable.php
?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Ref #</th>
<?php foreach ( $attributes as $name => $options) :?>
<th><?php echo $woocommerce->attribute_label($name); ?></th>
@simonlk
simonlk / get current taxonomy id
Created October 22, 2012 12:01
Get the details of the current taxonomy. This is for Woocommerce categories but would work for any custom taxonomies
<?php
$current_tax = get_query_var( 'product_cat' );
$term =get_term_by( 'slug', $current_tax, 'product_cat');
$term_name = $term->name;
$term_id = $term->term_id;
?>
@simonlk
simonlk / Woocommerce - show empty categories
Created October 21, 2012 06:33
Show empty categories within Woocommerce. Paste this in to your theme's functions file. It's just a copy and paste of a function within woocommerce-template.php and changing value of hide_empty to 0
// Paste this in to your theme's functions file
// Redefine sub category display to output empty categories
function woocommerce_product_subcategories( $args = array() ) {
global $woocommerce, $wp_query, $_chosen_attributes;
$defaults = array(
'before' => '',
'after' => '',
'force_display' => false
);