• Resolved teshn

    (@teshn)


    Hello folks,

    I can’t change the “add to cart” buttons in the archive page (homepage) to “view product” buttons. The shop page just works fine.

    add_filter( 'woocommerce_loop_add_to_cart_link', 'pg_replace_add_to_cart_button', 10, 2 );
    function pg_replace_add_to_cart_button( $button, $product ) {
        if (is_home() || is_product_category() || is_shop()) {
            $button_text = __("View Product", "woocommerce");
            $button_link = $product->get_permalink();
            $button = '<a href="' . $button_link . '" class="button product_type_simple add_to_cart_button ajax_add_to_cart">' . $button_text . '</a>';
            return $button;
    
        }
    }

    What could be the reason for that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • RK a11n

    (@riaanknoetze)

    Hi there,

    This is a fairly complex development topic and it might be worthwhile reaching out to the web developer community at large to review any code that you’ve already written.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    Finally, please note that this forum is focused on the Storefront theme specifically whereas the code you’re writing is aimed at the WooCommerce plugin itself.

    Niall a11n

    (@wpniall)

    Closing this thread, as the question relates to the WooCommerce plugin rather than the Storefront theme.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Not working: Changing “add to cart” to “view product” on archive page’ is closed to new replies.