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_custom_variable_price( $price, $product ) { | |
// Main Price | |
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); | |
$price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); | |
// Sale Price | |
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) ); | |
sort( $prices ); | |
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[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
<?php | |
function get_products_in_cart2() { | |
$cart_ids = array(); | |
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) { | |
$cart_product = $values['data']; | |
$cart_ids[] = $cart_product->id; | |
} | |
return $cart_ids; | |
} |
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
<?php | |
// Display subtitle after the header for posts and pages | |
add_action( 'storefront_single_post', 'storefront_add_subtitle_after_header', 15 ); | |
add_action( 'storefront_page', 'storefront_add_subtitle_after_header', 15 ); | |
function storefront_add_subtitle_after_header() { | |
the_subtitle( "<h2 class='subtitle'>", "</h2>" ); | |
} | |
// Display subtitle in the header for posts |
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_remove_password_strength() { | |
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) { | |
wp_dequeue_script( 'wc-password-strength-meter' ); | |
} | |
} | |
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 ); |
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_role_base_shipping_method( $rates, $package ) { | |
// Make sure flat rate is available | |
if ( isset( $rates['flat_rate'] ) && ! current_user_can( 'wholesale' ) ) { | |
unset($rates['flat_rate']); | |
} | |
return $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'wc_ninja_role_base_shipping_method', 10, 2 ); |
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_single_product_summary', 'wc_ninja_add_brand_to_product_page', 19 ); | |
function wc_ninja_add_brand_to_product_page() { | |
echo do_shortcode('[product_brand width="64px" height="64px" class="alignright"]'); | |
} |
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_sortable_taxonomies','wt_sort_brands' ); | |
function wt_sort_brands( $sortable ) { | |
$sortable[] = 'product_brand'; | |
return $sortable; | |
} |
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( 'the_author_posts_link', 'wc_ninja_change_author_url' ); | |
function wc_ninja_change_author_url($link) { | |
$username = get_the_author_meta('login'); | |
return "<a href='http://twitter.com/" . $username . "'>" . get_the_author() . "</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( 'restrict_manage_posts', 'wc_ninja_create_filter_dropdown' ); | |
function wc_ninja_create_filter_dropdown(){ | |
$type = 'product'; | |
if ( isset( $_GET['post_type'] ) ) { | |
$type = $_GET['post_type']; | |
} | |
if ( 'product' == $type ){ | |
$values = array( | |
'Catalog & search' => 'visible', |
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_bundle_requires_input', 'wc_ninja_require_bundle_input', 10, 2 ); | |
function wc_ninja_require_bundle_input( $requires_input, $product ) { | |
if ( ! $product->contains( 'mandatory' ) && $product->contains( 'optional' ) ) { | |
$requires_input = true; | |
} | |
return $requires_input; | |
} |