Home Forums WoodMart support forum Products (grid or carousel)

Products (grid or carousel)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #612399

    lemmermann
    Participant

    Hello Service Team,
    on our new website I want to change the button functionality from select options/add to cart “to go to productpage”.
    I think the most people want to see first the details from the produt before putting it to the cart.
    Is this possible ?

    Thanks for a short information.

    Best regards
    Mike

    Attachments:
    You must be logged in to view attached files.
    #612452

    Hello,

    Please try to add the code below in the functions.php file in your child theme.

    add_filter( 'woocommerce_loop_add_to_cart_link', 'redirect_variable_to_product_page', 10, 2 );
    function redirect_variable_to_product_page( $button, $product ) {
        // Get the product URL
        $url = get_permalink( $product->get_id() );
    
        // Check if the product is variable or simple
        if ( $product->is_type( 'variable' ) ) {
            $button = '<a href="' . esc_url( $url ) . '" class="button select_options">' . esc_html__( 'Select Options', 'woocommerce' ) . '</a>';
        } else {
            // Keep default for other product types
            $button = '<a href="' . esc_url( $url ) . '" class="button add_to_cart_button">' . esc_html( $product->add_to_cart_text() ) . '</a>';
        }
    
        return $button;
    }

    Best Regards

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