This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wc_ninja_change_backorder_button', 10, 2 ); | |
function wc_ninja_change_backorder_button( $text, $product ){ | |
if ( $product->is_on_backorder( 1 ) ) { | |
$text = __( 'Pre-Order', 'woocommerce' ); | |
} | |
return $text; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_after_shop_loop_item', 'wc_ninja_add_brands_to_archives', 6 ); | |
function wc_ninja_add_brands_to_archives() { | |
global $post; | |
$brand_count = sizeof( get_the_terms( $post->ID, 'product_brand' ) ); | |
$taxonomy = get_taxonomy( 'product_brand' ); | |
$labels = $taxonomy->labels; | |
echo get_brands( $post->ID, ', ', ' <div class="posted_in">' . sprintf( _n( '%1$s: ', '%2$s: ', $brand_count ), $labels->singular_name, $labels->name ), '</div>' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_attribute_label', 'wc_ninja_change_attribute_label', 20, 3 ); | |
function wc_ninja_change_attribute_label( $label, $name, $product ) { | |
// Check if on single product page and if the attribute name is 'color' | |
if ( is_product() && 'color' === $name ) { | |
global $product; | |
// Change the label text based on the product ID | |
switch ( $product->id ) { | |
case '357': | |
$label = 'Custom Label One'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_get_item_data', 'wc_ninja_add_custom_product_meta', 15, 2 ); | |
function wc_ninja_add_custom_product_meta( $other_data, $cart_item ) { | |
if ( ! empty( $cart_item['booking'] ) ) { | |
$item = $cart_item['booking']; | |
if ( 'night' === $item['_duration_unit'] ) { | |
$per_night = $item['_cost'] / $item['duration']; | |
$other_data[] = array( | |
'name' => 'Cost Per Night', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_after_cart_table', 'wc_ninja_remove_cart_addons' ); | |
function wc_ninja_remove_cart_addons() { | |
global $sfn_cart_addons; | |
remove_action( 'woocommerce_after_cart_table', array( $sfn_cart_addons, 'cart_display_addons' ), 20 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_ninja_change_shipping_rate_cost( $rates, $package ) { | |
$shipping_method_id = 'table_rate:14:1'; | |
$cost_per_case = 50; | |
$products_per_case = 12; | |
// Make sure the specific table rate is available | |
if ( isset( $rates[$shipping_method_id] ) ) { | |
$products_in_cart = WC()->cart->cart_contents_count; | |
$additional_cost = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_order_status_processing', 'wc_ninja_add_funds_at_processing', 5 ); | |
function wc_ninja_add_funds_at_processing( $order_id ) { | |
if ( method_exists( 'WC_Account_Funds', 'add_funds' ) ) { | |
wc_ninja_maybe_increase_funds( $order_id ); | |
} | |
} | |
function wc_ninja_maybe_increase_funds( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
$items = $order->get_items(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_after_cart_totals', 'wc_ninja_continue_shopping_button' ); | |
function wc_ninja_continue_shopping_button() { | |
$shop_page_url = wc_get_page_permalink( 'shop' ); | |
echo '<a href="' . $shop_page_url . '" class="button">Continue Shopping</a>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_archive_description', 'woocommerce_brand_image_custom', 18 ); | |
function woocommerce_brand_image_custom() { | |
if ( is_tax( 'product_brand' ) ){ | |
global $wp_query; | |
$category = $wp_query->get_queried_object(); | |
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); | |
$image = wp_get_attachment_url( $thumbnail_id ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_shipping_packages', 'wc_ninja_woocommerce_package_rates', 20 ); | |
function wc_ninja_woocommerce_package_rates( $packages ) { | |
$is_warm_weather = true; | |
foreach ( $packages as $package ) { | |
$has_candy = false; | |
foreach ( $package['contents'] as $cart_product ) { | |
if ( has_term( 'clothing', 'product_cat', $cart_product['product_id'] ) ) { | |
$has_candy = true; |