WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
How to change Add to Cart button to a Read More button? (24 posts)

  1. webmakerholly
    Member
    Posted 1 year ago #

    I am creating a shop for an art gallery website. Instead of using a Shop page, I am displaying the artwork for sale on each artists' page.

    I am using the shortcode: [product_category category="artist_name"] to automatically list any of that artist's work on his/her page. It's working so far but I would like to change the "Add to Cart" button to say "Read More" and link the button to the product description page.

    Any suggestions?
    Thanks!

    http://wordpress.org/extend/plugins/woocommerce/

  2. marc.kleinmann@gmail.com
    Member
    Posted 1 year ago #

    I would like to know how also.

  3. buzzcreations
    Member
    Posted 1 year ago #

    I also am looking for an answer to this.

    Thanks

  4. ameraz
    Member
    Posted 1 year ago #

    I would recommend as an alternative to change strings following this guide:

    http://docs.woothemes.com/document/woocommerce-localization/

  5. webmakerholly
    Member
    Posted 1 year ago #

    Ameraz, I appreciate your suggestion but I'm sure there must be an easier way than tricking the translation source.

    There must be a template page that specifies the name on the button and where the button links to. I'm a PHP novice so I'm having a hard time finding it but I'm sure it's in there somewhere.

    Do the developers read this forum? Anyone???

  6. Valentina Giorcelli
    Member
    Posted 12 months ago #

    news anyone? I am having the same problem.
    Thanx

    V.

  7. Kiseki Studio
    Member
    Posted 11 months ago #

    I was also trying to figure out a way to do this, fortunately for me all the products I wanted to have the Read More button on were virtual products so I amended this part of the add-to-cart.php file:

    default :
    				if ( $product->is_virtual() ) {
    					$link['url'] 	= apply_filters( 'not_purchasable_url', get_permalink( $product->id ) );
    					$link['label'] 	= apply_filters( 'not_purchasable_text', __( 'Read More', 'woocommerce' ) );
    				} elseif ( $product->is_purchasable() ) {
    					$link['url'] 	= apply_filters( 'add_to_cart_url', esc_url( $product->add_to_cart_url() ) );
    					$link['label'] 	= apply_filters( 'add_to_cart_text', __( 'Add to Cart', 'woocommerce' ) );
    					$link['class']  = apply_filters( 'add_to_cart_class', 'add_to_cart_button' );
    				} else {
    					$link['url'] 	= apply_filters( 'not_purchasable_url', get_permalink( $product->id ) );
    					$link['label'] 	= apply_filters( 'not_purchasable_text', __( 'Read More', 'woocommerce' ) );
    				}
    			break;

    I am overriding the Woocommerce theme with my own so I don't have to edit the file each time I upgrade.

    Not sure how helpful that is but it might give you some idea of how you could approach it for your own needs.

  8. bobbingwide
    Member
    Posted 11 months ago #

    Hi, I stumbled across this as I was looking for any forum threads related to [add_to_cart]. Although it doesn't immediately fulfill all the requirements to display the content exactly as the product_category shortcode you can get similar results using the oik plugin and the oik-fields plugin (which you can download FREE from oik-plugins.com )

    Instead of using
    [product_category category="artist_name"]
    the shortcode you'd use is
    [bw_pages post_type=product product_cat="artist_name" format="TI/E_Me" fields=_regular_price]

    If this is of interest AND/BUT you need more explanation please reply.

  9. bobbingwide
    Member
    Posted 11 months ago #

    I've created an example of the above suggestion.

    http://oik-plugins.eu/product-categories/

    Note: It's interesting that WooCommerce displays Read More for products which aren't priced!

  10. Valentina Giorcelli
    Member
    Posted 11 months ago #

    @Kiseki Studio: THank you for taking the time to paste your code! Sure it puts me in the right direction.
    @bobbingwide: I'll defenitely look into this plug in. Thanks.

    Funny how this issue on Jigoshop is solved as part of the setup options ..... to bad some other parts do not work as well ....

    Cheers

    V.

  11. makapa
    Member
    Posted 10 months ago #

    Hi,

    If someone still needs help regarding the issue described in the subject:
    you can do that by using the template files.

    1. the template file you are looking for is add-to-card.php, you can find it in \wp-content\plugins\woocommerce\templates\loop
    2. in order to override a template you simply need to go in your current theme folder (my case: themename-child) and create a similar folder tree (in this case \woocommerce\loop) - exclude the templates folder from this tree!
    3. copy the template file and make your changes

    This is it - should work now. More info here:
    http://docs.woothemes.com/document/template-structure/

    This works for all template files, so you can safely use it to make further enhancements to your site.

    _______________________________________________________________________
    Source: I did that for my custom child-theme as I didn't want to use localization. The settings should remain after the plugin & theme update - I didn't check if the setting remain after the update because I worked with all the latest updates included.

  12. Ahmad Mushtaq
    Member
    Posted 10 months ago #

    Hi,

    If someone still needs help regarding the issue described in the subject:
    you can do that by using the template files.

    1. the template file you are looking for is add-to-card.php, you can find it in \wp-content\plugins\woocommerce\templates\loop
    2. in order to override a template you simply need to go in your current theme folder (my case: themename-child) and create a similar folder tree (in this case \woocommerce\loop) - exclude the templates folder from this tree!
    3. copy the template file and make your changes

    This is it - should work now. More info here:
    http://docs.woothemes.com/document/template-structure/

    This works for all template files, so you can safely use it to make further enhancements to your site.

    _______________________________________________________________________
    Source: I did that for my custom child-theme as I didn't want to use localization. The settings should remain after the plugin & theme update - I didn't check if the setting remain after the update because I worked with all the latest updates included.

    Excellent! Thank you so much Makapa! This way my changes remain safe from theme and woocommerce updates! I have tried this and it workd flawlessly! :)

  13. digitalrenewal
    Member
    Posted 8 months ago #

    basically, leave the price off when youre creating the product.

  14. Moganic
    Member
    Posted 8 months ago #

    So is it possible to have that button even with the price ?

  15. joeleade
    Member
    Posted 4 months ago #

    Hi All,

    The below code works for me using WordPress 3.8.1 and WooCommerce 2.1.2. It will replace the "Add to Cart" button for Simple products on the Shop (product list) page with a "Read more" button that links to the single product page.

    In functions.php add the below code to remove the "Add to Cart" button:

    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );

    Now, add this code to create your own button:

    add_action( 'woocommerce_after_shop_loop_item', 'my_woocommerce_template_loop_add_to_cart', 10 );
    
    function my_woocommerce_template_loop_add_to_cart() {
        echo '<form action="' . get_permalink() . '" method="get">
                <button type="submit" class="single_add_to_cart_button button alt">Read More</button>
              </form>';
    }

    I've only tested in one theme, and haven't tried it using shortcodes. Hope it helps!

    Cheer,

    Joel

  16. Roy Ho
    Member
    Posted 4 months ago #

    This is all you need:

    add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_to_cart_loop' );
    
    function change_add_to_cart_loop( $product ) {
        global $product; // this may not be necessary as it should have pulled the object in already
    
        return '<a href="' . esc_url( $product->get_permalink( $product->id ) ) . '">READ MORE</a>';
    }
  17. joeleade
    Member
    Posted 4 months ago #

    Yes, that works too. Nice, although you lose the <button> element.

    I've changed mine to use some of your code:

    add_action( 'woocommerce_after_shop_loop_item', 'my_woocommerce_template_loop_add_to_cart', 10 );
    
    function my_woocommerce_template_loop_add_to_cart() {
        global $product;
        echo '<form action="' . esc_url( $product->get_permalink( $product->id ) ) . '" method="get">
                <button type="submit" class="single_add_to_cart_button button alt">View More</button>
              </form>';
    }

    Thanks!

  18. tozix
    Member
    Posted 3 months ago #

    Hi all, this code help me. But i have one question. I have shop with wpml. How can i translate the text in button? This code does not take me there. _e('Detail','theme-text-domain').

  19. joeleade
    Member
    Posted 3 months ago #

    Sorry, @tozix. I don't know the answer to that one.

  20. agrolsy
    Member
    Posted 3 months ago #

    Great, thanks!

    I just changed the code slightly to use the correct textdomain, thus enabling translation of the text View More

    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    add_action( 'woocommerce_after_shop_loop_item', 'my_woocommerce_template_loop_add_to_cart', 10 );
    
    function my_woocommerce_template_loop_add_to_cart() {
        global $product;
        echo '<form action="' . esc_url( $product->get_permalink( $product->id ) ) . '" method="get">
                <button type="submit" class="single_add_to_cart_button button alt">' . __('View More', 'woocommerce') . '</button>
              </form>';
    }
  21. joeleade
    Member
    Posted 3 months ago #

    Awesome work, @agrolsy. I'll update my code. Cheers!

  22. ibrus
    Member
    Posted 2 months ago #

    Hello from Russia! Unfortunatelly, the last code by agrolsy change only name of button, but when I click on button browser go at same page. Can you help me?
    Sorry for my English if i've got mistakes :)

  23. ashh115
    Member
    Posted 1 month ago #

    Thanks everyone. Worked a treat.

  24. respectyoda
    Member
    Posted 1 month ago #

    If you follow this link, you can easily change the text of the "Add to Cart" button.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic