Home Forums WoodMart support forum Replace “Add to Cart” by “Request a Quote” for specific category products ?

Replace “Add to Cart” by “Request a Quote” for specific category products ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #630470

    Chris
    Participant

    Hello,
    I created a new layout for ‘single product’ and I replaced the ‘add to cart’ button with ‘request a quote’ button (showing a request form) for all products in the ‘accessories’ category.
    How can I now hide or remove all the ‘add to cart’ buttons on the home page, product archive, quick view and related & upsells products only for the ‘accessories’ category (for example) with an add_action function or a css with display:none ?
    Thanks for your help.
    Best regards

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

    Chris
    Participant

    I got it working for all pages except for the popup ‘quick view’ !
    If you have an idea… ;)) Thanks. Best regards.

    document.addEventListener('DOMContentLoaded', function() {
        function retirerButtons() {
            document.querySelectorAll('.product_cat-accessories .wd-add-btn').forEach(button => {
                button.remove();
            });
        }
        retirerButtons();
        const produitContainer = document.querySelector('.products'); 
        if (produitContainer) {
            const observer = new MutationObserver(() => {
                retirerButtons(); 
            });
            observer.observe(produitContainer, { childList: true, subtree: true });
        }
    });
    #630995

    Hung Pham
    Keymaster

    Hi Chris,

    Thanks for reaching to us and appreciate your patience.

    Can you please try below one?

    document.addEventListener('DOMContentLoaded', function() {
        function retirerButtons() {
            document.querySelectorAll('.product_cat-accessories .wd-add-btn').forEach(button => {
                button.remove();
            });
        }
        retirerButtons();
        const produitContainer = document.querySelector('.products, . product-quick-view.product'); 
        if (produitContainer) {
            const observer = new MutationObserver(() => {
                retirerButtons(); 
            });
            observer.observe(produitContainer, { childList: true, subtree: true });
        }
    });

    Regards,

    #631117

    Chris
    Participant

    Thanks for your response.
    Best regards

    #631169

    Hung Pham
    Keymaster

    Hi Chris,

    Glad to hear your issue has been resolved. Keep us in mind for future questions and concerns, we’re always here to help!

    If you have a quick minute we always appreciate a 5-star rating on our theme!

    https://themeforest.net/item/woodmart-woocommerce-wordpress-theme/reviews/20264492

    Your feedback is the motivation to improve our work and services.

    Regards,

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

The topic ‘Replace “Add to Cart” by “Request a Quote” for specific category products ?’ is closed to new replies.