Jump to content

checkout page coding problem


Recommended Posts

I have modified the hook in a payment module to only show payment option if the total amount is above 1000 as below

if($cart->getOrderTotal() < 1000) {
       //     return ;
       return;
        }

 

This works great but I want to not show the payment option if someone puts a specific voucher code in there  eg

if($cart->getVoucherCode() = hhdyyhfyr) {
       //     return ;
       return;
        }

Obviously this is wrong. Is there a way of doing this for the checkout page or can I call it from database somewhere to check

Any help appreciated

Share this post


Link to post
Share on other sites

Hello,

Is your change displaying an error? 

Because the right PHP syntax should be this :

if($cart->getVoucherCode() == "hhdyyhfyr") {
       //     return ;
       return;
        }

Even if it's not the correct way to do this, there is an other method that allow you to handle more than one voucher code :

if( in_array($cart->getVoucherCode(), ["voucherCode1", "voucherCode2", "voucherCode3"]) ) {
       //     return ;
       return;
        }

 

There are 3 voucher codes in this example but you can put more. 

Edited by OutilGestionPro (see edit history)

Share this post


Link to post
Share on other sites

The problem is that I tried getVoucherCode() but I dont think this is even the correct way of getting the code

And before the order is created does it put it in the database anywhere I could just pull the information. I know once the order is created then you can get it from the database

 

 

Share this post


Link to post
Share on other sites

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More