woocommerce_cart_product_cannot_add_another_message, $message, $product_data

woocommerce_cart_product_cannot_add_another_message, $message, $product_data

Appears in:
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.11.0.0

apply_filters('woocommerce_cart_product_cannot_add_another_message, $message, $product_data') is found 2 times:

  • /includes/class-wc-cart-session.php line 631
    				if ( $found_in_cart ) {
    					/* translators: %s: product name */
    					$message = sprintf( __( 'You cannot add another "%s" to your cart.', 'woocommerce' ), $product_data->get_name() );
    					// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment -- Filter documented in WC_Cart::add_to_cart().
    					$message         = apply_filters( 'woocommerce_cart_product_cannot_add_another_message', $message, $product_data );
    					$wp_button_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '';
    					$message         = sprintf( '%s <a href="%s" class="button wc-forward%s">%s</a>', $message, esc_url( wc_get_cart_url() ), esc_attr( $wp_button_class ), __( 'View cart', 'woocommerce' ) );
    					wc_add_notice( $message, 'error' );
    					continue;
    				}
    			}
    
  • /includes/class-wc-cart.php line 1318
    					 * @since 4.5.0
    					 * @param string     $message Message.
    					 * @param WC_Product $product_data Product data.
    					 */
    					$message         = apply_filters( 'woocommerce_cart_product_cannot_add_another_message', $message, $product_data );
    					$wp_button_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '';
    
    					if ( ! CartCheckoutUtils::has_cart_page() ) {
    						$message = sprintf( '%s', esc_html( $message ) );
    					} else {
    						$message = sprintf( '%s <a href="%s" class="button wc-forward%s">%s</a>', $message, esc_url( wc_get_cart_url() ), esc_attr( $wp_button_class ), __( 'View cart', 'woocommerce' ) );