Disable purchase of online e-gift card upon code selectionShow cash on delivery option to registered users only?Hide Cash On Delivery Payment even when it is enabledvar payment_html is emptyCash on delivery payment method should visible only for some zip codes magento moduleDisable COD for other countriesChange status according to payment methodHow to setup Auto Invoice in Magento 2?How Restrict zip codes for Cash on delivery payment methodMagento 2 Hide Cash on Delivery Payment method only on one page checkout pageHow to hide COD payment method for specific product?

Recursively updating the MLE as new observations stream in

Should a narrator ever describe things based on a characters view instead of fact?

The English Debate

Why are there no stars visible in cislunar space?

Unfrosted light bulb

Do I need an EFI partition for each 18.04 ubuntu I have on my HD?

Emojional cryptic crossword

Pre-Employment Background Check With Consent For Future Checks

Error in master's thesis, I do not know what to do

Single word to change groups

Why does Surtur say that Thor is Asgard's doom?

Homology of the fiber

Nested Dynamic SOQL Query

Symbolism of 18 Journeyers

When did hardware antialiasing start being available?

Have any astronauts/cosmonauts died in space?

Why doesn't the fusion process of the sun speed up?

Hackerrank All Women's Codesprint 2019: Name the Product

How to balance a monster modification (zombie)?

Gauss brackets with double vertical lines

Why is there so much iron?

What is the difference between something being completely legal and being completely decriminalized?

Which partition to make active?

How to understand 「僕は誰より彼女が好きなんだ。」



Disable purchase of online e-gift card upon code selection


Show cash on delivery option to registered users only?Hide Cash On Delivery Payment even when it is enabledvar payment_html is emptyCash on delivery payment method should visible only for some zip codes magento moduleDisable COD for other countriesChange status according to payment methodHow to setup Auto Invoice in Magento 2?How Restrict zip codes for Cash on delivery payment methodMagento 2 Hide Cash on Delivery Payment method only on one page checkout pageHow to hide COD payment method for specific product?













1















Dears, how can I disable the purchase of Online e-gift card once the end user select the method of payment as: CASH ON DELIVERY? I don't want to let the users purchase an Online E-GIFT card and make the payment upon delivery?










share|improve this question
























  • I think you should disable COD for e-gift card products.

    – Pawan
    2 hours ago















1















Dears, how can I disable the purchase of Online e-gift card once the end user select the method of payment as: CASH ON DELIVERY? I don't want to let the users purchase an Online E-GIFT card and make the payment upon delivery?










share|improve this question
























  • I think you should disable COD for e-gift card products.

    – Pawan
    2 hours ago













1












1








1








Dears, how can I disable the purchase of Online e-gift card once the end user select the method of payment as: CASH ON DELIVERY? I don't want to let the users purchase an Online E-GIFT card and make the payment upon delivery?










share|improve this question
















Dears, how can I disable the purchase of Online e-gift card once the end user select the method of payment as: CASH ON DELIVERY? I don't want to let the users purchase an Online E-GIFT card and make the payment upon delivery?







magento-1.9 cash-on-delivery gift-card






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Pawan

1,9012617




1,9012617










asked 15 hours ago









MarcosMarcos

317




317












  • I think you should disable COD for e-gift card products.

    – Pawan
    2 hours ago

















  • I think you should disable COD for e-gift card products.

    – Pawan
    2 hours ago
















I think you should disable COD for e-gift card products.

– Pawan
2 hours ago





I think you should disable COD for e-gift card products.

– Pawan
2 hours ago










1 Answer
1






active

oldest

votes


















0














First you will need to create events.xml file under app/code/Company/Module/etc/. Then write “payment_method_is_active” event in it. This is the event which hits on checkout page for payment method availability.



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="payment_method_is_active">
<observer name="custom_payment" instance="CompanyModuleObserverPaymentMethodAvailable" />
</event>
</config>


Now create PaymentMethodAvailable.php under Company/Module/Observer/ and write following code in the file. I am disabling the CASH ON DELIVERY payment method when there is gift card in your cart (You can get the CheckoutSession and check if there is any gift card in cart)



<?php

namespace CompanyModuleObserver;

use MagentoFrameworkEventObserverInterface;


class PaymentMethodAvailable implements ObserverInterface

/**
* payment_method_is_active event handler.
*
* @param MagentoFrameworkEventObserver $observer
*/
public function execute(MagentoFrameworkEventObserver $observer)

$giftCardFlag = false;
if(//checkforcondition if giftCard in cart)
$giftCardFlag = true;


// you can replace "checkmo" with your required payment method code
if($observer->getEvent()->getMethodInstance()->getCode()=="youPaymentCode" && giftCardFlag)
$checkResult = $observer->getEvent()->getResult();
$checkResult->setData('is_available', false); //this is disabling the payment method at checkout page





Now the payment method CASH ON DELIVERY is disabled from checkout page .






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266377%2fdisable-purchase-of-online-e-gift-card-upon-code-selection%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    First you will need to create events.xml file under app/code/Company/Module/etc/. Then write “payment_method_is_active” event in it. This is the event which hits on checkout page for payment method availability.



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="payment_method_is_active">
    <observer name="custom_payment" instance="CompanyModuleObserverPaymentMethodAvailable" />
    </event>
    </config>


    Now create PaymentMethodAvailable.php under Company/Module/Observer/ and write following code in the file. I am disabling the CASH ON DELIVERY payment method when there is gift card in your cart (You can get the CheckoutSession and check if there is any gift card in cart)



    <?php

    namespace CompanyModuleObserver;

    use MagentoFrameworkEventObserverInterface;


    class PaymentMethodAvailable implements ObserverInterface

    /**
    * payment_method_is_active event handler.
    *
    * @param MagentoFrameworkEventObserver $observer
    */
    public function execute(MagentoFrameworkEventObserver $observer)

    $giftCardFlag = false;
    if(//checkforcondition if giftCard in cart)
    $giftCardFlag = true;


    // you can replace "checkmo" with your required payment method code
    if($observer->getEvent()->getMethodInstance()->getCode()=="youPaymentCode" && giftCardFlag)
    $checkResult = $observer->getEvent()->getResult();
    $checkResult->setData('is_available', false); //this is disabling the payment method at checkout page





    Now the payment method CASH ON DELIVERY is disabled from checkout page .






    share|improve this answer



























      0














      First you will need to create events.xml file under app/code/Company/Module/etc/. Then write “payment_method_is_active” event in it. This is the event which hits on checkout page for payment method availability.



      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
      <event name="payment_method_is_active">
      <observer name="custom_payment" instance="CompanyModuleObserverPaymentMethodAvailable" />
      </event>
      </config>


      Now create PaymentMethodAvailable.php under Company/Module/Observer/ and write following code in the file. I am disabling the CASH ON DELIVERY payment method when there is gift card in your cart (You can get the CheckoutSession and check if there is any gift card in cart)



      <?php

      namespace CompanyModuleObserver;

      use MagentoFrameworkEventObserverInterface;


      class PaymentMethodAvailable implements ObserverInterface

      /**
      * payment_method_is_active event handler.
      *
      * @param MagentoFrameworkEventObserver $observer
      */
      public function execute(MagentoFrameworkEventObserver $observer)

      $giftCardFlag = false;
      if(//checkforcondition if giftCard in cart)
      $giftCardFlag = true;


      // you can replace "checkmo" with your required payment method code
      if($observer->getEvent()->getMethodInstance()->getCode()=="youPaymentCode" && giftCardFlag)
      $checkResult = $observer->getEvent()->getResult();
      $checkResult->setData('is_available', false); //this is disabling the payment method at checkout page





      Now the payment method CASH ON DELIVERY is disabled from checkout page .






      share|improve this answer

























        0












        0








        0







        First you will need to create events.xml file under app/code/Company/Module/etc/. Then write “payment_method_is_active” event in it. This is the event which hits on checkout page for payment method availability.



        <?xml version="1.0"?>
        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
        <event name="payment_method_is_active">
        <observer name="custom_payment" instance="CompanyModuleObserverPaymentMethodAvailable" />
        </event>
        </config>


        Now create PaymentMethodAvailable.php under Company/Module/Observer/ and write following code in the file. I am disabling the CASH ON DELIVERY payment method when there is gift card in your cart (You can get the CheckoutSession and check if there is any gift card in cart)



        <?php

        namespace CompanyModuleObserver;

        use MagentoFrameworkEventObserverInterface;


        class PaymentMethodAvailable implements ObserverInterface

        /**
        * payment_method_is_active event handler.
        *
        * @param MagentoFrameworkEventObserver $observer
        */
        public function execute(MagentoFrameworkEventObserver $observer)

        $giftCardFlag = false;
        if(//checkforcondition if giftCard in cart)
        $giftCardFlag = true;


        // you can replace "checkmo" with your required payment method code
        if($observer->getEvent()->getMethodInstance()->getCode()=="youPaymentCode" && giftCardFlag)
        $checkResult = $observer->getEvent()->getResult();
        $checkResult->setData('is_available', false); //this is disabling the payment method at checkout page





        Now the payment method CASH ON DELIVERY is disabled from checkout page .






        share|improve this answer













        First you will need to create events.xml file under app/code/Company/Module/etc/. Then write “payment_method_is_active” event in it. This is the event which hits on checkout page for payment method availability.



        <?xml version="1.0"?>
        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
        <event name="payment_method_is_active">
        <observer name="custom_payment" instance="CompanyModuleObserverPaymentMethodAvailable" />
        </event>
        </config>


        Now create PaymentMethodAvailable.php under Company/Module/Observer/ and write following code in the file. I am disabling the CASH ON DELIVERY payment method when there is gift card in your cart (You can get the CheckoutSession and check if there is any gift card in cart)



        <?php

        namespace CompanyModuleObserver;

        use MagentoFrameworkEventObserverInterface;


        class PaymentMethodAvailable implements ObserverInterface

        /**
        * payment_method_is_active event handler.
        *
        * @param MagentoFrameworkEventObserver $observer
        */
        public function execute(MagentoFrameworkEventObserver $observer)

        $giftCardFlag = false;
        if(//checkforcondition if giftCard in cart)
        $giftCardFlag = true;


        // you can replace "checkmo" with your required payment method code
        if($observer->getEvent()->getMethodInstance()->getCode()=="youPaymentCode" && giftCardFlag)
        $checkResult = $observer->getEvent()->getResult();
        $checkResult->setData('is_available', false); //this is disabling the payment method at checkout page





        Now the payment method CASH ON DELIVERY is disabled from checkout page .







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        Vishwas BhatnagarVishwas Bhatnagar

        2,88122045




        2,88122045



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266377%2fdisable-purchase-of-online-e-gift-card-upon-code-selection%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sum ergo cogito? 1 nng

            三茅街道4182Guuntc Dn precexpngmageondP