• Resolved jazzu

    (@jazzu)


    Hello!

    As the title suggests, I want to replace all Add to cart buttons with View more buttons.
    It’s working fine for products with multiple variations, but I want the same button for simple products as well, so the button would open the product.

    So, I want these buttons to replace these buttons.

    I tried adding some solutions that I found on similar posts, but they don’t work.
    For example, this code:

    /* Remove add to cart button */
    add_action('woocommerce_before_shop_loop_item','remove_loop_add_to_cart_button'); 
    function remove_loop_add_to_cart_button(){
        global $product; // Current product
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); 
    }
    /* Add see details button to replace add to cart button*/
    add_action('woocommerce_after_shop_loop_item','replace_add_to_cart_with_view_product'); 
    function replace_add_to_cart_with_view_product() {
        global $product;
        $link = get_permalink(); 
        echo '<a class="button" href="' . esc_attr($link) . '">See Details</a>';
    }

    This code leaves all Add to cart buttons on simple products, leaves the some buttons for products with multiple variations untouched, and for some (ALSO variable products) removes the icon from the button, the red part of the button stays, but it does still take me to product page. You can see this here.

    What should I do?

    Thank you

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Replacing all Add to cart buttons with View details’ is closed to new replies.