Skip to content

Instantly share code, notes, and snippets.

add_filter( 'wc_password_strength_meter_params', 'my_strength_meter_custom_strings' );
function my_strength_meter_custom_strings( $data ) {
$data_new = array(
'i18n_password_error' => esc_attr__( 'Come on, enter a stronger password.', 'theme-domain' ),
'i18n_password_hint' => esc_attr__( 'The password should be at least seven characters long.', 'theme-domain' )
);
return array_merge( $data, $data_new );
}
@SirDarcanos
SirDarcanos / functions.php
Last active November 24, 2023 08:22
WooCommerce Bookings Reminder Email, Changing the Due Date
<?php
add_filter('woocommerce_bookings_remind_before_days', function() {
return 3;
});
add_action( 'woocommerce_archive_description', 'show_vendor_name_archive', 5 );
function show_vendor_name_archive() {
global $wp_query;
$term = $wp_query->queried_object;
if ( ! is_object( $term ) || empty( $term->term_id ) ) {
return;
}
@SirDarcanos
SirDarcanos / functions.php
Last active October 30, 2023 10:29
Change the “Add to Cart” text on the single product page, conditionally
<?php
add_filter( 'woocommerce_product_single_add_to_cart_text', 'change_add_to_cart_text', 10, 2 );
function change_add_to_cart_text( $default, $product ) {
$terms = get_the_terms( $product->id, 'product_cat' );
foreach ( $terms as $term ) {
if ( $term->name == 'Posters' ) {
$default = __( 'Custom Text', 'domain' );
break;
}
add_action( 'woocommerce_order_status_completed', 'change_role_on_purchase' );
function change_role_on_purchase( $order_id ) {
$order = wc_get_order( $order_id );
$items = $order->get_items();
$products_to_check = array( '1', '2', '3' );
foreach ( $items as $item ) {
if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check ) ) {
$user = new WP_User( $order->user_id );
@SirDarcanos
SirDarcanos / functions.php
Last active February 10, 2025 04:02
Make product attributes linkable
<?php
/**
* Register term fields for WooCommerce attributes.
*/
add_action( 'init', 'register_attributes_url_meta' );
function register_attributes_url_meta() {
$attributes = wc_get_attribute_taxonomies();
foreach ( $attributes as $tax ) {
$name = wc_attribute_taxonomy_name( $tax->attribute_name );
/**
* Redirect to a specific page when clicking on Continue Shopping in the single product page
*
* @return void
*/
function wc_custom_redirect_continue_shopping( $message ) {
if ( strpos( $message, __( 'View Cart', 'woocommerce' ) ) !== false ) {
$message = str_replace( esc_url( wc_get_page_permalink( 'cart' ) ), esc_url( wc_get_page_permalink( 'shop' ) ), $message );
$message = str_replace( __( 'View Cart', 'woocommerce' ), esc_html__( 'Continue Shopping', 'woocommerce' ), $message );
/* Menu color */
#navigation a {
color: #ff0000 !important;
}
/* Product categories widget */
.widget_product_categories a {
color: #ff0000 !important;
}
add_action( 'woocommerce_order_status_completed', 'change_role_on_purchase' );
function change_role_on_purchase( $order_id ) {
$order = wc_get_order( $order_id );
$items = $order->get_items();
$products_to_check = array( '1', '2', '3' );
foreach ( $items as $item ) {
if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check ) ) {
$role = 'new-role';
/**
* Change the Shop archive page title.
* @param string $title
* @return string
*/
function wc_custom_shop_archive_title( $title ) {
if ( is_shop() && isset( $title['title'] ) ) {
$title['title'] = 'My Title';
}