Hamendra Sunthwal Posted January 7, 2021 Share Posted January 7, 2021 ProductDownload::getIdFromIdProduct((int)($product['id_product'])); I am not sure what actually it fetches in PS. The issue is this "Pay by Cash on Delivery" payment method only appear on Giftcard product. I want to disable it for giftcard product also. Below is the code: public function hasProductDownload($cart) { $products = $cart->getProducts(); if (!empty($products)) { foreach ($products as $product) { $pd = ProductDownload::getIdFromIdProduct((int)($product['id_product'])); if ($pd and Validate::isUnsignedInt($pd)) { return true; } } } return false; } public function hookPaymentOptions($params) { if (!$this->active) { return; } // Check if cart has product download if ($this->hasProductDownload($params['cart'])) { return; } $newOption = new PaymentOption(); $newOption->setModuleName($this->name) ->setCallToActionText($this->trans('Pay by Cash on Delivery', array(), 'Modules.Cashondelivery.Shop')) ->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true)) ->setAdditionalInformation($this->fetch('module:ps_cashondelivery/views/templates/hook/ps_cashondelivery_intro.tpl')); $payment_options = [ $newOption, ]; return $payment_options; } Link to comment Share on other sites More sharing options...
tomerg3 Posted January 7, 2021 Share Posted January 7, 2021 The function return the ID of the product download, if it returns a value, it means the product is downloadable, and therefor COD is not displayed. Is your Giftcard a physical product, or a virtual one? Link to comment Share on other sites More sharing options...
Hamendra Sunthwal Posted January 8, 2021 Author Share Posted January 8, 2021 Issue with the code is, when product is downloadable then it shows the payment option. I am just trying to understand the code. would you help ? Link to comment Share on other sites More sharing options...
tomerg3 Posted January 8, 2021 Share Posted January 8, 2021 I tried, if you have another specific question, ask it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now