This file contains hidden or 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 | |
// Up-sells sorting | |
add_filter( 'woocommerce_upsells_orderby', function() { return 'date'; } ); | |
add_filter( 'woocommerce_upsells_order', function() { return 'desc'; } ); | |
// Cross-sells sorting | |
add_filter( 'woocommerce_cross_sells_orderby', function() { return 'date'; } ); | |
add_filter( 'woocommerce_cross_sells_order', function() { return 'desc'; } ); |
This file contains hidden or 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 | |
add_filter( 'woocommerce_table_rate_compare_price_limits_after_discounts', '__return_true' ); |
This file contains hidden or 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 | |
/** | |
* Remove the "nofollow" attribute from all comments author's links | |
* except for a specific author. | |
*/ | |
function dofollow_blog_author_comment( $return, $author ) { | |
if ( $author === 'Your Name' ) { | |
$return = str_replace( "rel='external nofollow ugc'", '', $return ); | |
} |
This file contains hidden or 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 | |
add_filter( 'woocommerce_cart_needs_payment', '__return_false' ); |
This file contains hidden or 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_order_barcodes_barcode_string', 'change_barcode_text' ); | |
function change_barcode_text( $barcode_string ) { | |
$barcode_class = WooCommerce_Order_Barcodes::get_instance(); | |
$order_id = barcode_class->get_barcode_order( $barcode_string ); | |
return $order_id; | |
} |
This file contains hidden or 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 | |
add_filter( 'woocommerce_add_to_cart_validation', 'wc_limit_one_per_order', 10, 2 ); | |
function wc_limit_one_per_order( $passed_validation, $product_id ) { | |
if ( 31 !== $product_id ) { | |
return $passed_validation; | |
} | |
if ( WC()->cart->get_cart_contents_count() >= 1 ) { | |
wc_add_notice( __( 'This product cannot be purchased with other products. Please, empty your cart first and then add it again.', 'woocommerce' ), 'error' ); | |
return false; |
This file contains hidden or 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 | |
add_action( 'after_setup_theme', 'remove_portfolio' ); | |
function remove_portfolio() { | |
remove_action( 'init', 'portfolio_register' ); | |
} |
This file contains hidden or 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 | |
add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_limit_by_category' ); | |
function wp_discord_post_limit_by_category( $post ) { | |
return has_category( array( 'Category 1', 'Category 2' ), $post ); | |
} |
This file contains hidden or 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 | |
add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_limit_by_category' ); | |
function wp_discord_post_limit_by_category( $post ) { | |
return has_category( 'Your Category Name', $post ); | |
} |
This file contains hidden or 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 | |
add_action( 'wp_loaded', 'woocommerce_empty_cart_action', 20 ); | |
function woocommerce_empty_cart_action() { | |
if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) { | |
WC()->cart->empty_cart(); | |
$referer = wp_get_referer() ? esc_url( remove_query_arg( 'empty_cart' ) ) : wc_get_cart_url(); | |
wp_safe_redirect( $referer ); | |
} | |
} |