Jump to content

[SOLVED] Duplicate buttons in checkout


Recommended Posts

  On 2/25/2025 at 10:57 AM, Catarina123 said:

3 buttons appear by default, and when I select the buttons they appear the same, what should I do?

Expand  

You mean you have 3 times the same Button? 
You need to tell us more.

Is it a virgen development, a reconstruct, an update issue?
is that the only issue?
What version/theme is it?

Edited by Nickz (see edit history)
Link to comment
Share on other sites

  On 2/25/2025 at 11:08 AM, Nickz said:

Quer dizer que você tem 3 vezes o mesmo botão?
Você precisa nos contar mais.

É um desenvolvimento virgem, uma reconstrução, um problema de atualização?
Esse é o único problema?

Expand  

I want that if the customer clicks on pay pal, only the pay pal option, when clicking on bank transfer or card, the option to finalize appears. It's always been like this, I don't know how to change it. In other words, when clicking on the payment method, the button corresponding to that method should appear and it doesn't.

Link to comment
Share on other sites

  On 2/25/2025 at 11:50 AM, Knowband Plugins said:

Most probably the theme issue. Have you checked with the theme support?

The theme does not hide the default "place order" button while PayPal is selected. 

 

Share the site URL?

Expand  

 

I already did it. I added custom javascript, in module Custom code module by ST-themes.

document.addEventListener("DOMContentLoaded", function () {
    // Seleciona todas as opções de pagamento (radio buttons)
    const paymentOptions = document.querySelectorAll("input[name='payment-option']");

    // Mapeia os containers dos botões de pagamento
    const paymentContainers = {
        "payment-option-2": document.querySelector("#ps_checkout-paypal-buttons-container"), // PayPal
        "payment-option-3": document.querySelector(".ps_checkout-button[data-funding-source='card']"), // Cartão de Crédito
        "payment-option-5": document.querySelector("#payment-confirmation") // Transferência Bancária, MbWay ou Revolut
    };

    // Esconder todos os botões ao carregar a página
    function hideAllButtons() {
        Object.values(paymentContainers).forEach(container => {
            if (container) container.style.display = "none";
        });
    }

    // Esconder tudo no início
    hideAllButtons();

    // Evento para mostrar apenas o botão correto quando um método é selecionado
    paymentOptions.forEach(option => {
        option.addEventListener("change", function () {
            hideAllButtons(); // Esconde todos os botões primeiro

            // Mostra apenas o botão correspondente ao método de pagamento escolhido
            if (paymentContainers[this.id]) {
                paymentContainers[this.id].style.display = "block";
            }
        });
    });
});

 

Link to comment
Share on other sites

  • Catarina123 changed the title to [SOLVED] Duplicate buttons in checkout

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...