• Resolved sirine2

    (@sirine2)


    It is possible to add buttonrent” in list product to redirect detail product , so the user have to go into the product page to follow the entire product requirements and select them

    Best Regards,

    • This topic was modified 8 months ago by sirine2.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there, @sirine2! Thanks for contacting us.

    I’m happy to help you. But do you mind sharing where exactly you want to add the button?

    As I understand you want to add a button names “rent” that would direct the user to the product page, correct? But I’m not clear as to where you want to add it. Can you share a URL and/or a screenshot so we can assist you further?

    Looking forward to your reply.

    Have a wonderful day!

    The below code will do this for ALL of your products. You would need to add a conditional if you wanted to do this only for specific products. The code first REMOVES the add to cart button and then replaces it with a new one that will force them to go to the product page.

    NOTE: This will only apply to the shop/archive page. It will not affect the single product page.

    function remove_loop_button() {
        remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
    }
    add_action('init', 'remove_loop_button');
    
    add_action('woocommerce_after_shop_loop_item', 'replace_add_to_cart');
    function replace_add_to_cart() {
        global $product;
        echo '<a class ="button product_type_simple add_to_cart_button ajax_add_to_cart" href="' . $product->get_permalink() . '">Rent</a><br/>';
    }

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add button “rent” in list product’ is closed to new replies.