Skip to content

Instantly share code, notes, and snippets.

View kloon's full-sized avatar
🌴
On vacation

Gerhard Potgieter kloon

🌴
On vacation
View GitHub Profile
@kloon
kloon / functions.php
Last active September 8, 2015 06:32
WooCommerce 2.1 Grouped product prices, revert to WooCommerce 2.0 format
<?php
// Place in your theme's functions.php file
// Revert grouped product prices to WooCommerce 2.0 format
add_filter( 'woocommerce_grouped_price_html', 'wc_wc20_grouped_price_format', 10, 2 );
function wc_wc20_grouped_price_format( $price, $product ) {
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$child_prices = array();
foreach ( $product->get_children() as $child_id ) {
$child_prices[] = get_post_meta( $child_id, '_price', true );
@kloon
kloon / functions.php
Last active September 8, 2015 06:32
WooCommerce 2.1 show trailing zeros
<?php
// Show trailing zeros on prices, default is to hide it.
add_filter( 'woocommerce_price_trim_zeros', 'wc_hide_trailing_zeros', 10, 1 );
function wc_hide_trailing_zeros( $trim ) {
// set to false to show trailing zeros
return false;
}
?>
@kloon
kloon / gist:3993329
Created November 1, 2012 12:22
WooCommerce Change Free price text
// Change free price text
function custom_free_price( $price, $product ) {
return '';
}
add_filter( 'woocommerce_free_sale_price_html', 'custom_free_price', 10, 2 );
add_filter( 'woocommerce_free_price_html', 'custom_free_price', 10, 2 );
add_filter( 'woocommerce_variable_free_price_html', 'custom_free_price', 10, 2 );
add_filter( 'woocommerce_variable_free_sale_price_html', 'custom_free_price', 10, 2 );
@kloon
kloon / gist:4015723
Last active October 12, 2015 10:48
WooCommerce Change empty price text
// Change empty price
function custom_empty_price( $price, $product ) {
return __( 'Call or Email for price', 'WooCommerce' ) ;
}
add_filter( 'woocommerce_variable_empty_price_html', 'custom_empty_price', 10, 2 );
add_filter( 'woocommerce_empty_price_html', 'custom_empty_price', 10, 2 );
@kloon
kloon / gist:4030229
Created November 7, 2012 08:39
WooCommerce Currency Convert Widget add currency code as class to <li>
jQuery( '.currency_switcher li a' ).each( function() {
jQuery( this ).parent().addClass( jQuery( this ).attr( 'data-currencycode' ) );
});
@kloon
kloon / gist:4218697
Created December 5, 2012 19:23
WooCommerce move sort dropdown to top of page
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 11 );
remove_action( 'woocommerce_pagination', 'woocommerce_catalog_ordering', 20 );
@kloon
kloon / gist:4239771
Created December 8, 2012 10:48
WooCommerce Name Your Price, show minimum price on archive pages
add_filter( 'woocommerce_get_price_html', 'woocommerce_nyp_min_price', 11, 2 );
function woocommerce_nyp_min_price( $price, $product ) {
if ( !$product->nyp )
return $price;
if( is_shop() || is_product_category() || is_product_tag() ) {
$price = woocommerce_price( $product->minimum );
}
return $price;
@kloon
kloon / gist:4326708
Created December 18, 2012 09:46
WooCommerce Remove Quantity from Product Page
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
function wc_remove_all_quantity_fields( $return, $product ) {
if ( is_product() )
return true;
else return $return;
}
@kloon
kloon / gist:4334989
Created December 19, 2012 07:03
WooCommerce remove Page from title of archive pages
function woocommerce_content() {
if ( is_singular( 'product' ) ) {
while ( have_posts() ) : the_post();
woocommerce_get_template_part( 'content', 'single-product' );
endwhile;
@kloon
kloon / gist:4386516
Created December 27, 2012 08:16
WooCommerce theme wrapper
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
function my_theme_wrapper_start() {
echo '<div class="fixed">';
echo '<div class="content-home-right">';
}
function my_theme_wrapper_end() {
echo '</div>';