Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 50;
if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text' );
function wc_custom_replace_sale_text( $html ) {
return str_replace( __( 'Sale!', 'woocommerce' ), __( 'My sale text!', 'woocommerce' ), $html );
}
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text' );
function wc_custom_replace_sale_text( $html ) {
return str_replace( __( 'Sale!', 'woocommerce' ), __( 'Offer!', 'woocommerce' ), $html );
}
/**
* Allows to duplicate products with the capability edit_products
*/
add_filter( 'woocommerce_duplicate_product_capability', create_function( '', 'return "edit_products";' ) );
@woogist
woogist / functions.php
Created March 3, 2015 07:31
Hides checkout fields based on the products in the cart
/**
* Hides checkout fields based on the products in the cart
*
* @param array $fields
* @return array
*/
function conditional_checkout_fields_products( $fields ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $item_key => $values ) {
/**
* Does not filter related products by tag
*/
add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
/**
* Does not filter related products by category
*/
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );
@woogist
woogist / krisi-choices-functions.php
Last active August 29, 2015 14:16
The code in below will integrate Sensei with the Choices theme from Krisi. Add the code below into your themes functions.php file.
/*********************
* Sensei Integration
*********************/
/**
* Declare that your theme now supports Sensei
*/
add_action( 'after_setup_theme', 'sensei_support' );
function sensei_support() {
add_theme_support( 'sensei' );
@woogist
woogist / genesis-functions.php
Last active December 20, 2017 01:51
The code in below will integrate Sensei with the Genesis theme framework from Studio Press. Add the code below into your themes functions.php file.
/*********************
* Sensei Integration
*********************/
/**
* Declare that your theme now supports Sensei
*/
add_action( 'after_setup_theme', 'sensei_support' );
function sensei_support() {
add_theme_support( 'sensei' );
@woogist
woogist / functions.php
Created February 27, 2015 08:39
Hides the Ninja Forms add-ons' prices in the cart and checkout pages
/**
* Hides the Ninja Forms add-ons' prices in the cart and checkout pages
*
* @param string $text
* @return string
*/
function wc_nf_hide_price( $text ) {
$text = strip_tags( $text ); // Strip HTML tags <span class="amount"></span>
$pattern ='/\s\([\D]+([\d]+[.?][\d]+)\)/';
@woogist
woogist / x-theme-functions.php
Last active March 2, 2018 20:56
The code below allow for Themeco - X Theme to be integrated with Sensei.
/**
* Declare that your theme now supports Sensei
*/
add_action( 'after_setup_theme', 'sensei_support' );
function sensei_support() {
add_theme_support( 'sensei' );
}
/**
* Remove the default Sensei wrappers