Home Forums Basel support forum Replace “Add to Cart” / category loop

Replace “Add to Cart” / category loop

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9847

    mobiflora
    Participant

    Hi xtemos,

    How can I replace “Add to Cart” button in category loop list with a link-button to single product page in woo commerce? So far I have the following code which removes the add to chart button and replaces it – but do_shortcode is not executed and all I get, is plain

    [button link=”http://mobiflora.de/shop/geburtstag/blumeideal-blumenstrau-chic/”%5DRead more[/button]

    Any Ideas or snippets?

    Thank you so much

    Till

    function remove_loop_button(){
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );
    }
    add_action(‘init’,’remove_loop_button’);

    /*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */

    add_action(‘woocommerce_after_shop_loop_item’,’replace_add_to_cart’);
    function replace_add_to_cart() {
    global $product;
    $link = $product->get_permalink();
    echo do_shortcode(‘<br>[button link=”‘ . esc_attr($link) . ‘”]Read more[/button]’);
    }

    #9853

    Artem Temos
    Keymaster

    Hello,

    Try to replace the function that displays new button with this one

    function replace_add_to_cart() {
    global $product;
    $link = $product->get_permalink();
    echo '<a href="'. esc_attr($link) .'" class="button">Read more</a>';
    }

    Regards

    #9892

    mobiflora
    Participant

    Hi xtemos,

    works like a charm… thanks.
    (close)

    #9901

    Artem Temos
    Keymaster

    You are welcome.

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