Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / functions.php
Created February 2, 2015 14:37
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(
'testo'
function nyp_move_minimum_price(){
$wc_name_your_price_display = WC_Name_Your_Price()->display;
remove_action( 'woocommerce_nyp_after_price_input', array($wc_name_your_price_display,'display_minimum_price'), 10 );
add_action( 'woocommerce_before_single_product', array( $wc_name_your_price_display, 'display_minimum_price' ) );
}
add_action( 'woocommerce_before_single_product' , 'nyp_move_minimum_price', 20 );
/**
* Adds a tab into the single product page for EXIF Data
*
* @param array $tabs
* @return array
*/
function wc_photography_exif_tab( $tabs ) {
global $product;
if ( $product->is_type( 'photography' ) ) {
/**
* Adds a tab into the single product page for EXIF Data
*
* @param array $tabs
* @return array
*/
function wc_photography_exif_tab( $tabs ) {
global $product;
if ( $product->is_type( 'photography' ) ) {
@woogist
woogist / functions.php
Created January 30, 2015 08:42
Print EXIF data for WC Photography
/**
* Adds a tab into the single product page for EXIF Data
*
* @param array $tabs
* @return array
*/
function wc_photography_exif_tab( $tabs ) {
$exif = array(
'title' => __( 'EXIF Data', 'domain' ),
'callback' => 'wc_photography_get_exif_data',
@woogist
woogist / functions.php
Created January 29, 2015 13:17
Set a custom add to cart URL to redirect to
/**
* Set a custom add to cart URL to redirect to
* @return string
*/
function custom_add_to_cart_redirect() {
return 'http://www.yourdomain.com/your-page/';
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
@woogist
woogist / functions.php
Created January 22, 2015 16:13
Prints the Google Analytics tracking code in the Thank you page.
/**
* Prints the Google Analytics tracking code in the Thank you page.
* @return void
*/
function wc_ga_conversion_tracking() {
if ( is_order_received_page() ) {
?>
<!-- PUT YOUR GA CODE HERE -->
<?php
}
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'] ) ) {
wp_redirect( 'http://www.yoururl.com/your-page/' );
exit;
}
}
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 ) );
}
@woogist
woogist / functions.php
Created January 21, 2015 15:47
Filters the page content adding the Thank you page contents
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['order'] ) ) {
return $content;