WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Woocommerce 2.1.1. change add to cart in to single product page (7 posts)

  1. Meceda
    Member
    Posted 1 year ago #

    This was the code i used before, with the current update it doesnt function anymore..

    Please help..

    /* replace add to cart text on button */
    add_filter('add_to_cart_text', 'woo_custom_cart_button_text');
    function woo_custom_cart_button_text() {
    return __('More Info', 'woocommerce');
    }
    /* remove add to cart class */
    add_filter('add_to_cart_class', 'woo_custom_cart_button_class');
    function woo_custom_cart_button_class() {
    return __('more_info_button', 'woocommerce');
    }
    /* make all products go to product page */
    add_filter( 'add_to_cart_url', 'woo_more_info_link' );
    function woo_more_info_link( $link ) {
    global $product; // switches link in all cases, i.e. in plugins
    $link = get_permalink( $product->id );
    return $link;
    }

    https://wordpress.org/plugins/woocommerce/

  2. vijfcent
    Member
    Posted 1 year ago #

    Same problem here. I used:

    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );

    function woo_custom_cart_button_text() {

    return __( 'My Button Text', 'woocommerce' );

    }

    After updating to 2.1.1 it displays standard text "add to cart" only. Woocommerce Poor guys swiss knife plugin cannot change the text either.

    On http://cursus.5ct.info/?post_type=product you may see what I mean; the Dutch version of "add to cart" is very long.

  3. Coen Jacobs
    Member
    Posted 1 year ago #

    The name of this filter changed. Use woocommerce_product_add_to_cart_text to change the text on the add to cart buttons and woocommerce_product_add_to_cart_url for the URL.

  4. Meceda
    Member
    Posted 1 year ago #

    Hello Coen,

    Thanks for your comment,

    The following code is what i and others are looking for, i have seen many questions on google about this topic.

    I need the "add to cart" text to change in to "view item"
    instead of adding it to the chart it needs to end up on the single product page.

    Could you past the code that we can put in to the functions.php?

  5. Coen Jacobs
    Member
    Posted 1 year ago #

    You would use it in the same way as in the code posted in your initial post in this topic, only with the new filter names as I provided in my response to that.

  6. Webprom Design
    Member
    Posted 1 year ago #

    Hi!

    What is the right new name for variable products?

  7. Ganga108
    Member
    Posted 2 months ago #

    Hey did someone resolved this problem ? i need code which will redirect add to cart to product page i tryed to use :

    /* make all products go to product page */
    add_filter( 'woocommerce_product_add_to_cart_url', 'woo_more_info_link' );
    function woo_more_info_link( $link ) {
    global $product; // switches link in all cases, i.e. in plugins
    $link = get_permalink( $product->id );
    return $link;
    }

    but it dont work :(

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic