Replace add to cart button

User
replace add to cart button at shop page for sepecif product type woocommerce
Assistant
Got it ✅ — you want to replace the **Add to Cart** button on the **shop/archive page** for a specific WooCommerce product type.
We can do this with the `woocommerce_loop_add_to_cart_link` filter.

Here’s a working snippet you can drop into your theme’s **functions.php** (or a custom plugin):

// Replace Add to Cart button for specific product type on shop/archive
add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_replace_add_to_cart_button', 10, 2 );
function custom_replace_add_to_cart_button( $button, $product ) {
    
    // Change this to your product type, e.g. 'simple', 'variable', 'external', or your custom type
    if ( $product->get_type() === 'your_product_type' ) {
        
        // Example: Replace with a custom link or button
        $button = '<a href="' . esc_url( get_permalink( $product->get_id() ) ) . '" class="button alt">View Details</a>';
        
        // Or completely custom button
        // $button = '<button class="button custom-btn">Custom Action</button>';
    }

    return $button;
}

🔧 **How to adjust**:
– Replace `'your_product_type'` with your target type (e.g. `simple`, `variable`, `grouped`, `external`, or your **custom product type**).
– Update the HTML inside `$button` to whatever you need (custom text, link to product page, popup trigger, etc.).

👉 Do you want this for a **default WooCommerce type** (like variable/simple) or for a **custom product type** (like your Probo configurable product)?

Leave a Comment

Your email address will not be published. Required fields are marked *