Home Forums Basel support forum Change "Add to Cart" text in grid view

Change "Add to Cart" text in grid view

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15707

    svaldesm
    Participant

    Hello,

    I want to change the text, the function is listed here:

    
    echo apply_filters( 'woocommerce_loop_add_to_cart_link',
    	sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
    		esc_url( $product->add_to_cart_url() ),
    		esc_attr( isset( $quantity ) ? $quantity : 1 ),
    		esc_attr( $product->get_id() ),
    		esc_attr( $product->get_sku() ),
    		esc_attr( isset( $class ) ? $class : 'button' ),
    		esc_html( $product->add_to_cart_text() )
    	),
    $product );
    

    It is located in “add-to-cart.php” inside /loop.

    The main issue is that I want to add a phrase with a line break (<br/>) but it is not working.
    I’m changing the esc_html() but it’s definitely not working.

    How can I change that text? It also adds a layer of “basel-tooltip-label” span before.

    Thanks!

    #15708

    Artem Temos
    Keymaster

    Hi,

    Try to use this code instead

    echo apply_filters( 'woocommerce_loop_add_to_cart_link',
    	sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">Text<br>with break</a>',
    		esc_url( $product->add_to_cart_url() ),
    		esc_attr( isset( $quantity ) ? $quantity : 1 ),
    		esc_attr( $product->get_id() ),
    		esc_attr( $product->get_sku() ),
    		esc_attr( isset( $class ) ? $class : 'button' )
    	),
    $product );

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)