Custom Add To Cart Button Text Based on Product Attribute Slug in WooCommerce

$50.00

This PHP code for WooCommerce enables you to display custom text in replace of the default add to cart text on the shop page, based on the product variation attribute slug. You can see the attribute slug =on the Product > Attributes page in your WordPress Dashboard.

Based on the product attribute for color, the add to cart text in the button is changed to “Get Quote” as seen here :

The code only changes the add to cart text if the product

Installation

There’s only 1 step : Copy and paste the PHP code to the end of your child themes functions.php or custom functionality/code snippets plugin.

Attribute Slug

Grab your attribute slug from the Products > Attributes page and swap out the slug in the code on lines 15 and 17.

You can also change the add to cart text on line 19.