Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1345534

    Hello, please go to https://www.caspersmeets.nl/product/maxisys-ms906s/
    I would like to add a second button right next to the original ‘Toevoegen aan winkelwagen’ button. This button has to be redirected to another specific page on the website. Is this possible?
    Thanks!

    #1345602

    Hey EricSmeets,
    I assume that you want this button on every product page and it will lead to the same specific page.
    Try adding this code to the end of your functions.php file in Appearance ▸ Editor:

    function custom_button_next_to_product_button() { ?>
    <script>
    (function($){
    $('.single-product .single-product-summary').each(function() {
      $('<button class="button buttonLink">Een andere specifieke pagina</button>').insertAfter('.single_add_to_cart_button').css({ 'margin-left': '3%' });
    });
    $('.buttonLink').click(function(e){
      e.preventDefault();
      window.location.href = "https://google.com";
    });
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_button_next_to_product_button');

    then adjust the link to suit.

    Best regards,
    Mike

    #1347155

    Hello Mike,

    thanks a lot. It works perfectly. However I don’t want it for every product. Is it possible to pick specific items for this function? How would this work?

    Kind regards, Eric Smeets.

    #1347203

    Hi,
    Glad to hear, to use this on only a specific product you can add the page ID to the .single-product class in the function, for example this product page you linked to above would be .postid-1365.single-product
    If it is for multiple products and you have a list of page IDs then I could adjust the script, how many do you expect there to be, and do you feel that you could add and remove the page IDs to the script as you needed?
    Do all of these have something in common like the same category?

    Best regards,
    Mike

    #1347333

    Yes, I understand what you mean and have altered the code to my needs. One question remains.
    How would I alter the code if I want all the products in the category named ‘MaxiSys’ to have this extra button?

    #1347383

    Hi,

    Thanks for the update. Please try changing this:

    .single-product .single-product-summary

    To this:

    .single-product .product_cat-MaxiSys .single-product-summary

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.