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
// Orders products by stock, putting out-of-stock ones to the end of the shop and category archives | |
add_filter( 'posts_clauses', 'order_by_stock_status' ); | |
function order_by_stock_status( $args ) { | |
global $wpdb; | |
$join_suffix = $args['join']; | |
if ( is_woocommerce() && !is_admin() ) { | |
$args['join'] = " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id " . $join_suffix; | |
$args['orderby'] = ' wc_product_meta_lookup.stock_status ASC, wc_product_meta_lookup.product_id DESC '; |
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
// Appends Affiliates URL parameter and ID in every URL, when the affiliate cookie exists | |
add_action( 'template_redirect', 'affiliates_pname_redirect' ); | |
function affiliates_pname_redirect() { | |
$pname = get_option( 'aff_pname', AFFILIATES_PNAME ); | |
if( isset( $_COOKIE[AFFILIATES_COOKIE_NAME] ) && !$_GET[$pname] ) { | |
$location = esc_url( add_query_arg( $pname, $_COOKIE[AFFILIATES_COOKIE_NAME] ) ); | |
wp_redirect( $location ); | |
} | |
} |
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
// Adds a hyphen to the product SKU right after three characters starting from the left | |
add_filter ( 'woocommerce_product_search_indexer_filter_content', 'example_woocommerce_product_search_indexer_filter_content', 10, 3 ); | |
function example_woocommerce_product_search_indexer_filter_content( $content, $context, $post_id ) { | |
if ( $context === 'post_content' ) { | |
$product = wc_get_product( $post_id ); | |
if ( $product ) { | |
$product_sku = $product->get_sku(); | |
$alternative_product_sku = substr_replace( $product_sku, '-', 3, 0 ); | |
$content .= ' ' . $alternative_product_sku; | |
} |
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( 'affiliates_totals_export_file_headings', 'example_affiliates_totals_export_file_headings' ); | |
function example_affiliates_totals_export_file_headings( $headings ) { | |
$headings[] = 'Data'; | |
return $headings; | |
} | |
add_filter( 'affiliates_totals_export_file_line', 'example_affiliates_totals_export_file_line', 10, 4 ); | |
function example_affiliates_totals_export_file_line( $line, $affiliate_id, $user_id, $result ) { | |
$extra_field = get_user_meta( $user_id, 'extra_field', 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_before_shop_loop', 'example_woo_list_categories' ); | |
/** | |
* Action Callback | |
*/ | |
function example_woo_list_categories() { | |
$result = false; | |
$output = ''; | |
if ( is_product_category() ) { | |
$queried_object = get_queried_object(); |
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_search_field_product_description', 'wpsrd_woocommerce_product_search_field_product_description', 10, 2 ); | |
function wpsrd_woocommerce_product_search_field_product_description( $description, $post_id ) { | |
if ( $post_id == 32 ) { // here you should use the product id you desire instead of 32 | |
$description = 'a description'; // write a description enclosed in single quotes | |
} | |
return $description; | |
} |
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( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 ); | |
function custom_shop_order_column($columns) { | |
$reordered_columns = array(); | |
// Inserting columns to a specific location | |
foreach( $columns as $key => $column){ | |
$reordered_columns[$key] = $column; | |
if ( $key == 'order_status' ) { | |
// Inserting after "Status" column | |
$reordered_columns['my-column1'] = esc_html( 'Referrer' ); |
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( 'affiliates_thanks_sign_up_text', 'example_affiliates_thanks_sign_up_text' ); | |
function example_affiliates_thanks_sign_up_text( $text ) { | |
// the default text is this: | |
$text = '<p>' . esc_html__( 'Thanks for signing up!', 'affiliates' ) . '</p>'; | |
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_account_downloads', 'example_woocommerce_after_account_downloads' ); | |
function example_woocommerce_after_account_downloads() { | |
if ( | |
class_exists( 'Groups_Group' ) && | |
class_exists( 'Groups_User_Group' ) | |
) { | |
$group_ids = Groups_Group::get_group_ids(); | |
$user_id = get_current_user_id(); | |
foreach ( $group_ids as $group_id ) { | |
if ( Groups_User_Group::read( $user_id, $group_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( 'affiliates_supported_currencies', 'example_affiliates_supported_currencies' ); | |
function example_affiliates_supported_currencies( $currencies ) { | |
$currencies[] = 'INR'; | |
return $currencies; | |
} |
NewerOlder