Stripe Payment

Remove payment module if only virtual products in basket - Stripe Payment

Remove payment module if only virtual products in basket

by 14Steve14 » Sat May 25, 2024 2:47 pm

Hi Rainer

Can you just confirm that I have done the right thing. We sell both free and paid for downloads and occasionally a customer only buys free items. Obviously we don't want the payment module to show so have changed the code so it looks like

Code: Select all

function __construct() {
      global $order, $payment;
      
      // disable the module if the order only contains virtual products
            if ( 'virtual' === $GLOBALS['order']->content_type ) {
                $this->enabled = false;

                return;
            }
It does seem to hide the module and when required the module does seem to work so I assume that it must be correct. Can you confirm that the change is correct please.

Steve
14Steve14
Senior Contributor
Posts: 922
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Contact:

Re: Remove payment module if only virtual products in basket

by raiwa » Sat May 25, 2024 3:05 pm

Looks good
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: Remove payment module if only virtual products in basket

by 14Steve14 » Sat May 25, 2024 4:04 pm

Cheers for that. It dod look like it work, but me and my lack of confidence just needed to check.
14Steve14
Senior Contributor
Posts: 922
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Contact: