Jump to content

What does this function mean ?


Hamendra Sunthwal
 Share

Recommended Posts

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;
    }
 

Share this post


Link to post
Share on other sites

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?

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