Skip to content

Instantly share code, notes, and snippets.

@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
);
@simonlk
simonlk / Woocommerce - output product variations in tab
Last active February 21, 2022 20:27
Output Woocommerce product variations as a table within a tab on the single product page
// Add to functions.php
/*===================================================
Created by sk from Renegade Empire with help
from these sources:
http://docs.woothemes.com/document/editing-product-data-tabs/
http://www.sean-barton.co.uk/2013/03/remove-woocommerce-20-reviews-tab/#.UYnWe7XfB6N
http://www.sean-barton.co.uk/2013/03/sb-add-woocommerce-tabs-wordpress-plugin/#.UYrYL7XfB6M
@simonlk
simonlk / WooCommerce - Change Sort Code to BSB
Created January 8, 2014 06:28
Change "Sort Code" to "BSB" for Bacs payment method
function wpse_77783_woo_bacs_ibn($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'Sort Code':
$translation = 'BSB';
break;
}
}
@simonlk
simonlk / wc-name-your-price-cart-url
Created March 26, 2014 03:12
WooCommerce Name Your Price Plugin add to cart by URL
This isn't code, just a tip that will hopefully get picked up by search engines for anyone that needs it (me when I have this problem next).
domain.com/cart/?add-to-cart=15998&credit_called[15998]=44
Where 15998 is the product ID
@simonlk
simonlk / Wordpress - change login image login url and url title
Created November 2, 2012 05:44
Wordpress - change login image, login url and url title
// add this to your themes functions.php file
// change login image
add_action("login_head", "my_login_head");
function my_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('template_url')."/assets/img/image-name.png') no-repeat scroll center top transparent;
height: 59px;
}
@simonlk
simonlk / Wooocommerce - add description field to product variations
Created November 6, 2012 14:13
Add a description input field for each product variation that saves to post_content
<?php
/**
* Variable Product Type
*
* Functions specific to variable products (for the write panels).
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/WritePanels
* @version 1.6.4
@simonlk
simonlk / WooCommerce add to cart text
Created August 17, 2013 00:30
Change add to cart button text on single product page. For some reason it doesn't work if the text "Add to Cart" is used so double spacing makes it work. WTF.
/* Add to cart button text */
add_filter('single_add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
return __('Add to Cart', 'woocommerce');
}
// First remove default wrapper
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
// Then add new wrappers
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 '<section id="main">';
@simonlk
simonlk / acf-repeater-field
Created July 16, 2013 04:57
ACF Repeater field usage in functions.php using hook
/*=========================================
ACF Repeater
======================================== */
add_action( 'woo_post_inside_after', 're_acf_repeater', 10); // hook is the first part
function re_acf_repeater () { ?>
<?php if(get_field('field_name')): ?>
<ul>
<?php while(has_sub_field('field_name')) { ?>
@simonlk
simonlk / WooCommerce quantity box as dropdown
Created August 17, 2013 00:23
Change the quantity inbox box to a dropdown. Add to theme/woocommerce/single-product/add-to-cart/quantity.php
<?php
/**
* Single product quantity inputs
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly