Easystore hide proceed to payment button when order amount is lower than .... - Forum | JoomShaper
Staff replied EasyStore

Easystore hide proceed to payment button when order amount is lower than ....

Asked by justmikey 1 year ago Last activity 1 year ago

I want to have a short code or something to 'hide' the PROCEED TO PAYMENT button when a order is below € 10.000,00 on checkout page.

Is that possible? Maybe with CSS or hardcoded? Pls help, very needed.

14 replies

Atick Eashrak Shuvo Staff

Apolozy for the inconvenience. Unfortunately, there is no built-in setting to achieve this. However, it is possible to implement this using custom JavaScript by dynamically checking the order total and hiding the "Proceed to Payment" button if the amount is below a value. Please add the following JS code to your Template Options -> Custom Code -> Custom JS

document.addEventListener("DOMContentLoaded", function () {
    function updateButtonState() {
        let priceElement = document.querySelector(".easystore-list-value");
        let button = document.querySelector(".btn.btn-primary.btn-lg.w-100.mb-4");

        if (priceElement && button) {
            let priceText = priceElement.textContent.trim().replace(/[^0-9.]/g, ''); // Remove non-numeric characters
            let price = parseFloat(priceText);

            if (!isNaN(price) && price < 200) {
                button.setAttribute("disabled", "disabled"); // Disable button
                button.style.display = "none"; // Hide button
            } else {
                button.removeAttribute("disabled"); // Enable button
                button.style.display = ""; // Show button
            }
        }
    }

    updateButtonState(); // Run once on load

    const observer = new MutationObserver(updateButtonState);
    let targetNode = document.querySelector(".easystore-list-value");

    if (targetNode) {
        observer.observe(targetNode, { childList: true, subtree: true, characterData: true });
    }
});

Replace the '200' value according to your preference

justmikey Asked this

Hi,thank you. gonna try that. Can i also add a rule with text 'proceding not possible below € ... " when amount is below our minimal amount ?

Atick Eashrak Shuvo Staff

You can try this one.

document.addEventListener("DOMContentLoaded", function () {
    function updateButtonState() {
        let priceElement = document.querySelector(".easystore-list-value");
        let button = document.querySelector(".btn.btn-primary.btn-lg.w-100.mb-4");

        if (priceElement && button) {
            let priceText = priceElement.textContent.trim().replace(/[^0-9.]/g, ''); // Remove non-numeric characters
            let price = parseFloat(priceText);

            if (!isNaN(price) && price < 200) {
                button.setAttribute("disabled", "disabled"); // Disable button
                button.textContent = "Proceeding Not Possible Below €200"; // Change text
            } else {
                button.removeAttribute("disabled"); // Enable button
                button.textContent = "Proceed to Payment"; // Restore original text
            }
        }
    }

    updateButtonState(); 


    const observer = new MutationObserver(updateButtonState);
    let targetNode = document.querySelector(".easystore-list-value");

    if (targetNode) {
        observer.observe(targetNode, { childList: true, subtree: true, characterData: true });
    }
});

Replace 200 with your desire price. Please use integer value.

justmikey Asked this
1 year ago · edited

It doesnt work well... I changed the parameter to 10000.

Now,

  • below € 100 order the button is disabled
  • After € 100 - € 1000 button enabled
  • After € 1000 button disabled, even after € 10.000 it is still disabled...
    Don't understand.

Just curious --->
Is there also a 'small ' code for a seperate (none button) text BELOW the button where stands:
you need to order € xxx more to pass the € 10.000 limit?
Would be great!!

Atick Eashrak Shuvo Staff

Hi there!

Thank you for bringing this to our attention, and I sincerely apologize for the inconvenience caused.

To assist you more effectively, may I kindly request temporary administrative access to your site? This will allow me to thoroughly investigate and resolve the issue for you.

Before sharing the credentials, I strongly recommend taking a complete backup of your site to ensure all data remains secure.

Looking forward to your response.

Best regards

justmikey Asked this
1 year ago · edited

seehidden

justmikey Asked this

Hello, any idea how to fix?

Atick Eashrak Shuvo Staff

I apologize for the inconvenience and the delayed response due to the weekend. I am currently working on your issue and would appreciate your confirmation on the minimum price you would like to set.

Looking forward to your response.

justmikey Asked this

Amount is 10.000€
Lower than 10.000 not possible to order
Highter than 10.000 possible

Atick Eashrak Shuvo Staff

Apolozy for the inconvenience. I’m a bit confused due to the difference in numbering formats. Could you please confirm whether you mean 10k or 10 without the separator? This will help us ensure accurate processing.

justmikey Asked this

10000 euro.
But the website is changing the values to 10.000 itselfs because of seperator. That is always in EUR.

x.xxx,xx thousands
xxx,xx hundreds

Atick Eashrak Shuvo Staff

Please provide your site super user access

justmikey Asked this

I have changed.

Atick Eashrak Shuvo Staff

You said it worked partially before, could you please put the code which worked partially?

justmikey Asked this

See hidden

Atick Eashrak Shuvo Staff

Could you confirm is it partially working?

But it only work between 100 and 1000 euro for what i've tested. Doesnt work anymore after 1000>. Ofcourse changed the 200 value to 10000.

justmikey Asked this
1 year ago · edited

No, when set to 10.000 the button to proceed to payment still appears < 1000€.
After € 1000 it disappears and after 10.000 it is still dissapeared.

So the button needs to be disappeared between 0 and 10.000€....

justmikey Asked this

Do you have any idea? Why it partly work?

justmikey Asked this

Hello
any updates?

Log in to reply.