Skip to content

Instantly share code, notes, and snippets.

View wbcomdev's full-sized avatar

Wbcom Dev wbcomdev

View GitHub Profile
/**
* Remove product content based on category.
*/
function wb_remove_product_content() {
// If a product in the 'Music' category is being viewed.
if ( is_product() && has_term( 'Music', 'product_cat' ) ) {
// Remove the images.
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
// For a full list of what can be removed please see woocommerce-hooks.php.
}
/**
* Auto Complete all WooCommerce orders.
*/
function wb_custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
/**
* Add a 1% surcharge to your cart / checkout.
* change the $percentage to set the surcharge to a value to suit.
*/
function wb_woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
/**
* Add a standard $ value surcharge to all transactions in cart / checkout.
*/
function wb_wc_add_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
/**
* Add a 1% surcharge to your cart / checkout based on delivery country.
* Taxes, shipping costs and order subtotal are all included in the surcharge amount.
*/
function wb_woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
/**
* Rename "home" in breadcrumb.
*/
function wb_wc_change_breadcrumb_home_text( $defaults ) {
// Change the breadcrumb home text from 'Home' to 'Apartment'.
$defaults['home'] = 'Apartment';
return $defaults;
}
add_filter( 'woocommerce_breadcrumb_defaults', 'wb_wc_change_breadcrumb_home_text' );
/**
* Change the breadcrumb separator.
*/
function wb_wc_change_breadcrumb_delimiter( $defaults ) {
// Change the breadcrumb delimeter from '/' to '>'
$defaults['delimiter'] = ' > ';
return $defaults;
}
add_filter( 'woocommerce_breadcrumb_defaults', 'wb_wc_change_breadcrumb_delimiter' );
/**
* Change several of the breadcrumb defaults.
*/
function wb_woocommerce_breadcrumbs() {
return array(
'delimiter' => ' / ',
'wrap_before' => '<nav class="woocommerce-breadcrumb" itemprop="breadcrumb">',
'wrap_after' => '</nav>',
'before' => '',
'after' => '',
/**
* Remove the breadcrumbs.
*/
function wb_woo_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
add_action( 'init', 'wb_woo_remove_wc_breadcrumbs' );
/**
* Remove breadcrumbs for Storefront theme.