Skip to content

Instantly share code, notes, and snippets.

@simonlk
simonlk / Woocommerce - hide other shipping methods when free shipping is available
Created November 27, 2012 04:41
Woocommerce - hide other shipping methods when free shipping is available
// Based on http://wcdocs.woothemes.com/snippets/hide-other-shipping-methods-when-free-shipping-is-available/
// Goes beyond by hiding the default internation shipping too
// Hide shipping options when free shipping is available
add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 );
/**
* Hide Standard Shipping option when free shipping is available
*
* @param array $available_methods
*/
@simonlk
simonlk / Woocommerce - change paypal icon
Created November 28, 2012 00:41 — forked from mikejolley/gist:1425282
This snippet lets you edit the icon for the PayPal gateway in WooCommerce.
// Change the paypal icon
add_filter('woocommerce_paypal_icon', 'custom_woocommerce_paypal_icon');
function custom_woocommerce_paypal_icon( $url ) {
$url = get_bloginfo('template_url')."/assets/img/payment-icons.png";
return $url;
}
@simonlk
simonlk / WooCommerce - change "Choose an option" to be the name of the attribute
Last active December 16, 2015 18:39
WooCommerce - change "Choose an option" to be the name of the attribute
// Looks up the slug of the attribute and manually replaces it with the text
// Within single-product/add-to-cart/variable.php replace the line:
// <option value=""><?php echo __( 'Choose an option', 'woocommerce' ) ?>&hellip;</option>
<option value="">
<?php
if ($name == 'pa_colour') {
$attr_name = 'Colour';
} elseif ($name == 'pa_size') {
$attr_name = 'Size';
}
@simonlk
simonlk / WooCommerce - related products from author
Created April 30, 2013 09:31
Replace the related products area with products by the same author
@simonlk
simonlk / WooCommerce - wrap the price in a div
Created May 2, 2013 06:05
Change the output of the price to include additional tags
add_filter( 'woocommerce_get_price_html', 'warnies_price_html', 100, 2 );
function warnies_price_html( $price, $product ){
return '<div class="price">' . $price . '</div>';
}
@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 Remove sort order drop down
Created August 16, 2013 23:41
Remove sort order drop down
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
@simonlk
simonlk / WooCommerce - remove result count
Created August 16, 2013 23:54
Blank function overrides the existing function so it doesn't call the template
function woocommerce_result_count() {}
@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
@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');
}