Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / cyberychimps-functions.php
Created February 24, 2015 23:10
The code below allow for Cyberchimps - Pro starter 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
@woogist
woogist / functions.php
Last active July 15, 2024 08:39
The code below adds Sensei support to your Divi Theme. To use it simply copy it to your Divi functions.php file.
/**
* Declare Sensei support
*
* This is needed to hide the Sensei theme compatibility notice your admin dashboard.
*/
add_action( 'after_setup_theme', 'divi_sensei_support' );
function divi_sensei_support() {
add_theme_support( 'sensei' );
}
add_action( 'woocommerce_admin_order_item_headers', 'wc_msrp_headers' );
function wc_msrp_headers() {
?><th class="item_msrp sortable"><?php _e( 'MSRP', 'woocommerce' ); ?></th><?php
}
add_action( 'woocommerce_admin_order_item_values', 'wc_msrp_order_item_values' );
function wc_msrp_order_item_values( $_product ) {
$msrp = get_post_meta( absint( $_product->id ), '_msrp_price', true );
printf( '<td class="item_msrp">%s</td>', ( $msrp ? wc_price( $msrp ) : '-' ) );
}
@woogist
woogist / functions.php
Created February 24, 2015 10:56
Shows MSRP in the order items
add_action( 'woocommerce_admin_order_item_headers', 'wc_msrp_headers' );
function wc_msrp_headers() {
?><th class="item_msrp sortable"><?php _e( 'MSRP', 'woocommerce' ); ?></th><?php
}
add_action( 'woocommerce_admin_order_item_values', 'wc_msrp_order_item_values' );
function wc_msrp_order_item_values( $_product ) {
$msrp = get_post_meta( absint( $_product->id ), '_msrp_price', true );
printf( '<td class="item_msrp">%s</td>', wc_price( $msrp ) );
}
add_filter( 'woocommerce_add_to_cart_redirect', 'wc_custom_cart_redirect' );
function wc_custom_cart_redirect() {
return get_permalink( wc_get_page_id( 'shop' ) );
}
@woogist
woogist / functions.php
Created February 11, 2015 10:00
Changes the redirect URL for the Return To Shop button in the cart.
/**
* Changes the redirect URL for the Return To Shop button in the cart.
*
* @return string
*/
function wc_empty_cart_redirect_url() {
return 'http://yourdomain.com/your-page/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
add_action( 'wc_custom_thankyou_failed', 'wc_custom_thankyou_failed', 10 );
function wc_custom_thankyou_failed( $order ) {
wc_get_template( 'custom-thankyou/failed.php', array( 'order' => $order ) );
}
add_action( 'wc_custom_thankyou_successful', 'wc_custom_thankyou_header', 10 );
function wc_custom_thankyou_header( $order ) {
wc_get_template( 'custom-thankyou/header.php', array( 'order' => $order ) );
}
add_filter( 'the_content', 'wc_custom_thankyou' );
function wc_custom_thankyou( $content ) {
// Check if is the correct page
if ( ! is_page( {PAGE_ID} ) ) {
return $content;
}
// check if the order ID exists
if ( ! isset( $_GET['key'] ) || ! isset( $_GET['order'] ) ) {
return $content;
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
$order_id = absint( $wp->query_vars['order-received'] );
$order_key = wc_clean( $_GET['key'] );
$redirect = get_permalink( {PAGE_ID} );
$redirect .= get_option( 'permalink_structure' ) === '' ? '&' : '?';
@woogist
woogist / functions.php
Created February 2, 2015 14:49
Hides the cost for free checkout add-ons
/**
* Hides the cost for free checkout add-ons
*
* @param string $html
* @param object $fee
* @return string
*/
function wc_hide_fee_cost( $html, $fee ) {
$hide_for = array(
'add-on-slug',