1
votes

I am using the code below to replace add to cart button with a linked button to the product in Shop, related products and archives pages only

add_action( 'woocommerce_after_shop_loop_item', 'shop_view_product_button', 10);
    function shop_view_product_button() {
    global $product;
    $link = $product->get_permalink();
    echo '<a href="' . $link . '" class="button addtocartbutton">View Product</a>';
}

But I need to change the add to cart button text on the single product page to "Apply".

Any help?

1

1 Answers

1
votes

Use the following:

add_filter( 'woocommerce_product_single_add_to_cart_text', 'product_single_add_to_cart_custom_text', 20, 1 );
function product_single_add_to_cart_custom_text( $text ) {
    $text = __( 'Apply', 'woocommerce' );

    return $text;
}