Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active May 15, 2024 06:22
Show Gist options
  • Save braddalton/2683fb90c0285516ff0f75cf6d11d541 to your computer and use it in GitHub Desktop.
Save braddalton/2683fb90c0285516ff0f75cf6d11d541 to your computer and use it in GitHub Desktop.
Replace the Add To Cart Text with a Shopping Cart Icon In WooCommerce. Download Full Code https://wpsites.net/?p=115948
// Enqueue Font Awesome
function enqueue_font_awesome() {
wp_enqueue_style( 'font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
// Change "Add to Cart" button text to a shopping cart icon
function custom_add_to_cart_text() {
echo '<i class="fas fa-shopping-cart"></i>'; // Font Awesome shopping cart icon
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_text' ); // For single product pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment