Disable Payment Method

The purpose of this module is to disable a payment displayed for the basket, if the basket contains articles, which are assigned to a (hidden) category mapping to a Diasallowance of a Payment:

Put this as file htr_payment inside modules

and activate in the Admin Backend in System ->Modules:

payment => htr_payment

<?php /** * disallow payment by having a $_aCatDiasallowPayment = array ('noinvoice'=>'oxidinvoice') assignment.
this would mean in above case : 
Articles assigned to the (hidden/ or not hidden, e.g. eBooks by invoice makes no sense) category 'noinvoice'
will disable the payment option oxidinvoice for all the  basket
class htr_payment extends htr_payment_parent
    protected $_aCatDiasallowPayment = array ('noinvoice'=>'oxidinvoice');
    public function getPaymentList()
        if (is_null($this->_oPaymentList)) {
            $oBasket = $this->getSession()->getBasket();
            $oPaymentList = parent::getPaymentList();
            $oCategory = new oxCategory();
            foreach($oBasket->getBasketArticles() as $key=>$oArticle){
                $aCatIds = $oArticle->getCategoryIds();
                foreach ($aCatIds as $sId){
                    #$title = $oCategory->getTitle();
                    # for compability reasons (OXID <4.5 do it this way: $title = $oCategory->oxcategories__oxtitle->getRawValue();
                    if (array_key_exists($title, $this->_aCatDiasallowPayment)){
                        foreach ($oPaymentList as $key=>$oPayment){
                            $sOxid = $oPayment->_sOXID;
                            if ($sOxid == $this->_aCatDiasallowPayment[$title]){
                                unset ($this->_oPaymentList[$this->_aCatDiasallowPayment[$title]]);
        return $this->_oPaymentList;

Shared by holgt

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *