Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:3d3e932fddc9c36abc87
Last active August 29, 2015 14:08
AffiliateWP + WooCommerce - Add link through to user's profile screen from the reference column of the referrals page
<?php
/**
* Add link through to user's profile screen from the reference column of the referrals page
*/
function affwp_custom_wc_referrals_user_link( $reference, $referral ) {
if ( ! ( 'woocommerce' == $referral->context || class_exists( 'WC_Order' ) ) ) {
return $reference;
}
@mikejolley
mikejolley / gist:11171530
Last active May 16, 2019 06:42 — forked from woogist/gist:6065863
Hide all/some shipping options when free shipping is available
/**
* woocommerce_package_rates is a 2.1+ hook
*/
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
/**
* Hide shipping rates when free shipping is available
*
* @param array $rates Array of rates found for the package
* @param array $package The package array/object being shipped
@corsonr
corsonr / gist:7370707
Created November 8, 2013 13:00
WooCommerce - display order coupons used in confirmation email and edit order page
add_action( 'woocommerce_email_after_order_table', 'add_payment_method_to_admin_new_order', 15, 2 );
/**
* Add used coupons to the order confirmation email
*
*/
function add_payment_method_to_admin_new_order( $order, $is_admin_email ) {
if ( $is_admin_email ) {
@thenbrent
thenbrent / wcs-redirect-to-cart.php
Last active July 29, 2021 14:51
Redirect customers to the cart page when adding a subscription to their cart (rather than the checkout page, which is the default).
<?php
/**
* Plugin Name: WooCommerce Subscriptions Redirect to Cart
* Description: Redirect customers to the cart page when adding a subscription to their cart (rather than the checkout page, which is the default).
* Author: Gerhard Potgieter & Brent Shepherd
* Author URI: http://www.woothemes.com/products/woocommerce-subscriptions/
* Version: 1.0
* License: GPL v2
*/
@BFTrick
BFTrick / gettext-filter-multiple.php
Last active March 30, 2023 07:18
Use the gettext WordPress filter to change any translatable string.
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Sale!' :
$translated_text = __( 'Clearance!', 'woocommerce' );
@webaware
webaware / gist:6260468
Last active October 28, 2024 06:19
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@jazbek
jazbek / gist:5959855
Created July 9, 2013 18:26
Fix Canvas theme temporarily
<?php
add_action( 'init', 'tribe_events_wootheme_compatibility' );
function tribe_events_wootheme_compatibility() {
if ( ! is_home() ) {
remove_filter( 'pre_get_posts', 'woo_exclude_categories_homepage', 10 );
}
}
@jameskoster
jameskoster / functions.php
Last active October 5, 2020 17:34
WooCommerce - Remove product data tabs
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;