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 | |
// Change add to cart text on single product page | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'change_add_to_cart_text' ); | |
function change_add_to_cart_text() { | |
return 'Add to Bag'; | |
} |
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 | |
// Change add to cart text on single product page | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'change_add_to_cart_text' ); | |
function change_add_to_cart_text() { | |
return 'Add to Bag'; | |
} | |
// Change add to cart text on product archives page | |
add_filter( 'woocommerce_product_add_to_cart_text', 'change_add_to_cart_text_archives' ); | |
function change_add_to_cart_text_archives() { |
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 | |
// Predefined email address | |
define('HIDDEN_EMAIL_ORDERS', '[email protected]'); | |
// Add the checkbox | |
function add_email_filter_checkbox() { | |
global $typenow; | |
if ( 'shop_order' == $typenow ) { | |
$is_checked = isset( $_GET['hide_specific_email'] ) ? 'checked' : ''; |
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 | |
// Filter orders based on the entered email | |
function filter_orders_by_emails( $query ) { | |
global $typenow, $wpdb; | |
if ( 'shop_order' == $typenow && isset( $_GET['filter_emails'] ) && !empty( $_GET['filter_emails'] ) ) { | |
$emails = array_map('sanitize_email', explode(',', $_GET['filter_emails'])); | |
$order_ids = $wpdb->get_col( "SELECT pm.post_id FROM {$wpdb->postmeta} pm WHERE pm.meta_key = '_billing_email' AND pm.meta_value IN ('" . join("','", $emails) . "')" ); |
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 the input field | |
function add_email_filter() { | |
global $typenow; | |
if ( 'shop_order' == $typenow ) { | |
$current_emails = isset( $_GET['filter_emails'] ) ? sanitize_text_field( $_GET['filter_emails'] ) : ''; | |
echo '<input type="text" name="filter_emails" placeholder="Hide orders by email" value="' . esc_attr( $current_emails ) . '">'; | |
} | |
} |
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 | |
function show_specific_customer_orders($query) { | |
global $pagenow, $typenow; | |
if (!is_admin() || !$query->is_main_query() || 'shop_order' !== $typenow || 'edit.php' !== $pagenow || !isset($_GET['filter_email']) || empty($_GET['filter_email'])) { | |
return; | |
} | |
$email_to_filter = sanitize_email($_GET['filter_email']); | |
$customer_orders = wc_get_orders(array('limit' => -1, 'customer' => $email_to_filter, 'return' => 'ids')); |
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 | |
function add_email_filter_to_orders() { | |
global $typenow; | |
if ('shop_order' === $typenow) { | |
echo '<input type="text" name="filter_email" placeholder="Email Address..." value="' . (isset($_GET['filter_email']) ? esc_attr($_GET['filter_email']) : '') . '">'; | |
} | |
} | |
add_action('restrict_manage_posts', 'add_email_filter_to_orders', 99); |
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_countries_allowed_countries', 'wc_ban_russia' ); | |
function wc_ban_russia( $countries ) { | |
if ( isset( $countries['RU'] ) ) { | |
unset( $countries['RU'] ); | |
} | |
return $countries; | |
} |
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_get_price_html', 'wc_edit_bookable_remove_from_price', 10, 2 ); | |
function wc_edit_bookable_remove_from_price( $html, $product ) { | |
if ( ! $product->is_type( 'booking' ) ) { | |
return $html; | |
} | |
return str_replace( 'From: ', '', $html ); | |
} |
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
/** | |
* Plugin Name: Show Short Description on the Shop Page | |
* Plugin URI: https://nicolamustone.blog/2016/12/01/show-products-short-description-shop-page/#comment-2119 | |
* Description: Shows the product's short description on the shop page with WooCommerce. | |
* Version: 1.0 | |
* Author: Nicola Mustone | |
* Author URI: https://nicolamustone.blog | |
*/ | |
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 ); |