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( 'storefront_featured_products_args', 'wc_ninja_edit_sf_featured_products_args', 10 ); | |
function wc_ninja_edit_sf_featured_products_args( $args ) { | |
$args['orderby'] = "ID"; | |
$args['order'] = "asc"; | |
return $args; | |
} |
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_upsells_total', 'wc_ninja_edit_upsells_total', 10 ); | |
function wc_ninja_edit_upsells_total( $limit ) { | |
return 8; | |
} | |
add_filter( 'woocommerce_upsells_columns', 'wc_ninja_edit_upsells_columns', 10 ); | |
function wc_ninja_edit_upsells_columns( $columns ) { | |
return 4; | |
} |
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_add_to_cart_url', 'wc_ninja_edit_add_to_cart_url', 10, 2 ); | |
function wc_ninja_edit_add_to_cart_url( $url, $product ) { | |
if ( 'simple' === $product->get_type() ) { | |
$url = $product->get_permalink(); | |
} | |
return $url; | |
} | |
add_filter( 'woocommerce_product_add_to_cart_text', 'wc_ninja_edit_add_to_cart_text', 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_filter( 'woocommerce_paypal_express_checkout_button_img_url', 'wc_ninja_change_paypal_logo', 10, 2 ) | |
function wc_ninja_change_paypal_logo( $image, $size ) { | |
return 'https://example.com/wp-content/uploads/2017/03/custom-paypal-checkout-button.jpg'; | |
} |
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; |
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_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_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
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_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 ); | |
} |