• Resolved jazzu

    (@jazzu)


    Hello!

    I need every single product to show up with a view more button instead of add to cart button.

    Most of the products are variable, so they are not a problem.
    However, I have a few Simple products (not variable) that already had the View more button below. I noticed that the product that’s making problems for me gets the view more button if I place it into the same category AND leave it in the old one, so it’s in both categories – AND it gets the view more button in BOTH categories (“Zunanje savne” tab has only simple products and it’s the category that I moved the product into. The product that’s making issues is located in “Oprema – Pe?i – Vega Compact)

    I don’t know why that’s happening, I checked out the differences, but nothing is different product wise. The only difference is that the location of the product is in a subcategory and other products are directly in a category.

    I also tried a few codes, for example the one below. This one ALMOST works, the only issue is that the add to cart button gets replaced with a blank button (no icon, no tooltip), however, it takes you to product details, which is correct.

    // changes the "select options" text. Forget who to give credit to for this.
    add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) {
    global $product;
    if ( $product->is_type( 'variable' ) ) {
        $text = $product->is_purchasable() ? __( 'More Options', 'woocommerce' ) : __( 'Read more', 'woocommerce' );
    }
    return $text;
    }, 10 );
    
    /**
     * remove add to cart buttons on shop archive page
     */
    
    add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );
    function replacing_add_to_cart_button( $button, $product  ) {
    if ( $product->is_type( 'simple' ) ) {
    $button_text = __("View product", "woocommerce");
    $button = '<a class="button" href="' . $product->get_permalink() . '">' . 
    $button_text . '</a>';
    }
    return $button;
    }

    Link to category that has simple products and shows the view more button, just the way I want it: https://moja-savna.si/kategorija-izdelka/zunanje-savne/

    Link of the product that’s making issues for me: https://moja-savna.si/kategorija-izdelka/oprema/peci/

    Really hope someone is able to help me out.

    Thank you!

    • This topic was modified 3 years ago by jazzu.
    • This topic was modified 3 years ago by Yui.

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

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Need every product to have View more instead of Add to cart button’ is closed to new replies.