how to get all coupon code which can apply on cart page in magento 2How to apply coupon codes for each product separately which are in the cart?Get a coupon code to send in welcome emailsame coupon code should apply for diferent conditionsHow to apply only valid coupon codes to shopping cart programmatically?Apply Magento Coupon in Ajax Without Redirecting to Cart PageApply coupon code only for specific categoryMagento 2:- Apply custom coupon codeProgramatically apply coupon code in magento 2.2How to get Coupon Code on Success Page in Magento 2how to retrieve Coupon Code by rule Id on Checkout Success Page?

Information to fellow intern about hiring?

What happens when a metallic dragon and a chromatic dragon mate?

Why was the "bread communication" in the arena of Catching Fire left out in the movie?

Does it makes sense to buy a new cycle to learn riding?

How can I add custom success page

Why does this relative pronoun not take the case of the noun it is referring to?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Is domain driven design an anti-SQL pattern?

Latin words with no plurals in English

New order #4: World

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

I am not able to install anything in ubuntu

How to create a consistant feel for character names in a fantasy setting?

Deciding between multiple birth names and dates?

Copycat chess is back

Was there ever an axiom rendered a theorem?

Why doesn't a const reference extend the life of a temporary object passed via a function?

Can I find out the caloric content of bread by dehydrating it?

What is GPS' 19 year rollover and does it present a cybersecurity issue?

Are cabin dividers used to "hide" the flex of the airplane?

Can I legally use front facing blue light in the UK?

Shall I use personal or official e-mail account when registering to external websites for work purpose?

How can I fix this gap between bookcases I made?



how to get all coupon code which can apply on cart page in magento 2


How to apply coupon codes for each product separately which are in the cart?Get a coupon code to send in welcome emailsame coupon code should apply for diferent conditionsHow to apply only valid coupon codes to shopping cart programmatically?Apply Magento Coupon in Ajax Without Redirecting to Cart PageApply coupon code only for specific categoryMagento 2:- Apply custom coupon codeProgramatically apply coupon code in magento 2.2How to get Coupon Code on Success Page in Magento 2how to retrieve Coupon Code by rule Id on Checkout Success Page?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















How to get all coupon code which can apply on cart page in magento 2



$getRules = $objectManager->create('MagentoSalesRuleModelRule')->getCollection();



using the above code i get the all list of coupon codes. I want to display coupon code which can apply










share|improve this question
























  • I want to show list of valid coupon on cart page

    – satish
    Apr 5 at 8:38

















0















How to get all coupon code which can apply on cart page in magento 2



$getRules = $objectManager->create('MagentoSalesRuleModelRule')->getCollection();



using the above code i get the all list of coupon codes. I want to display coupon code which can apply










share|improve this question
























  • I want to show list of valid coupon on cart page

    – satish
    Apr 5 at 8:38













0












0








0








How to get all coupon code which can apply on cart page in magento 2



$getRules = $objectManager->create('MagentoSalesRuleModelRule')->getCollection();



using the above code i get the all list of coupon codes. I want to display coupon code which can apply










share|improve this question
















How to get all coupon code which can apply on cart page in magento 2



$getRules = $objectManager->create('MagentoSalesRuleModelRule')->getCollection();



using the above code i get the all list of coupon codes. I want to display coupon code which can apply







magento2 coupon-codes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 5 at 7:36







satish

















asked Apr 5 at 7:27









satishsatish

16912




16912












  • I want to show list of valid coupon on cart page

    – satish
    Apr 5 at 8:38

















  • I want to show list of valid coupon on cart page

    – satish
    Apr 5 at 8:38
















I want to show list of valid coupon on cart page

– satish
Apr 5 at 8:38





I want to show list of valid coupon on cart page

– satish
Apr 5 at 8:38










1 Answer
1






active

oldest

votes


















0














I have created block to get cart items using checkout session file name is CustomSession.php



protected $_checkoutSession;

public function __construct (
MagentoCheckoutModelSession $_checkoutSession
)
$this->_checkoutSession = $_checkoutSession;


public function getProducts()

$item = $this->_checkoutSession->getQuote()->getAllVisibleItems();
return $item;



than overriding the coupon.phtml file



 $objectManager = MagentoFrameworkAppObjectManager::getInstance();
$objectManager->create('MagentoCatalogModelSession');
$objectManager->create('MagentoCatalogModelSession');
$CatalogSession = $objectManager->get('MagentoCatalogModelSession');
$blockObj= $block->getLayout()->createBlock('SatishContactBlockCustomSession');
$SalesRule = $objectManager->create('MagentoSalesRuleModelRule');
$getRules = $SalesRule->getCollection();
$item = $objectManager->create('MagentoCatalogModelProduct');

$products = $blockObj->getProducts(); // this will also work using custom session block
foreach ($products as $product)
foreach ($getRules as $rule)
$rules = $SalesRule->load($rule->getId());
$item->setProduct($product);
$validate = $rules->getActions()->validate($product);
if ($validate == true)

echo "coupon -".$rule->getCode()."'>".$rule->getCode()." - ".$rule->getDescription()." coupon";
echo "<br>";
# code...
else
continue;








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%2f268875%2fhow-to-get-all-coupon-code-which-can-apply-on-cart-page-in-magento-2%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














    I have created block to get cart items using checkout session file name is CustomSession.php



    protected $_checkoutSession;

    public function __construct (
    MagentoCheckoutModelSession $_checkoutSession
    )
    $this->_checkoutSession = $_checkoutSession;


    public function getProducts()

    $item = $this->_checkoutSession->getQuote()->getAllVisibleItems();
    return $item;



    than overriding the coupon.phtml file



     $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $objectManager->create('MagentoCatalogModelSession');
    $objectManager->create('MagentoCatalogModelSession');
    $CatalogSession = $objectManager->get('MagentoCatalogModelSession');
    $blockObj= $block->getLayout()->createBlock('SatishContactBlockCustomSession');
    $SalesRule = $objectManager->create('MagentoSalesRuleModelRule');
    $getRules = $SalesRule->getCollection();
    $item = $objectManager->create('MagentoCatalogModelProduct');

    $products = $blockObj->getProducts(); // this will also work using custom session block
    foreach ($products as $product)
    foreach ($getRules as $rule)
    $rules = $SalesRule->load($rule->getId());
    $item->setProduct($product);
    $validate = $rules->getActions()->validate($product);
    if ($validate == true)

    echo "coupon -".$rule->getCode()."'>".$rule->getCode()." - ".$rule->getDescription()." coupon";
    echo "<br>";
    # code...
    else
    continue;








    share|improve this answer



























      0














      I have created block to get cart items using checkout session file name is CustomSession.php



      protected $_checkoutSession;

      public function __construct (
      MagentoCheckoutModelSession $_checkoutSession
      )
      $this->_checkoutSession = $_checkoutSession;


      public function getProducts()

      $item = $this->_checkoutSession->getQuote()->getAllVisibleItems();
      return $item;



      than overriding the coupon.phtml file



       $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $objectManager->create('MagentoCatalogModelSession');
      $objectManager->create('MagentoCatalogModelSession');
      $CatalogSession = $objectManager->get('MagentoCatalogModelSession');
      $blockObj= $block->getLayout()->createBlock('SatishContactBlockCustomSession');
      $SalesRule = $objectManager->create('MagentoSalesRuleModelRule');
      $getRules = $SalesRule->getCollection();
      $item = $objectManager->create('MagentoCatalogModelProduct');

      $products = $blockObj->getProducts(); // this will also work using custom session block
      foreach ($products as $product)
      foreach ($getRules as $rule)
      $rules = $SalesRule->load($rule->getId());
      $item->setProduct($product);
      $validate = $rules->getActions()->validate($product);
      if ($validate == true)

      echo "coupon -".$rule->getCode()."'>".$rule->getCode()." - ".$rule->getDescription()." coupon";
      echo "<br>";
      # code...
      else
      continue;








      share|improve this answer

























        0












        0








        0







        I have created block to get cart items using checkout session file name is CustomSession.php



        protected $_checkoutSession;

        public function __construct (
        MagentoCheckoutModelSession $_checkoutSession
        )
        $this->_checkoutSession = $_checkoutSession;


        public function getProducts()

        $item = $this->_checkoutSession->getQuote()->getAllVisibleItems();
        return $item;



        than overriding the coupon.phtml file



         $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $objectManager->create('MagentoCatalogModelSession');
        $objectManager->create('MagentoCatalogModelSession');
        $CatalogSession = $objectManager->get('MagentoCatalogModelSession');
        $blockObj= $block->getLayout()->createBlock('SatishContactBlockCustomSession');
        $SalesRule = $objectManager->create('MagentoSalesRuleModelRule');
        $getRules = $SalesRule->getCollection();
        $item = $objectManager->create('MagentoCatalogModelProduct');

        $products = $blockObj->getProducts(); // this will also work using custom session block
        foreach ($products as $product)
        foreach ($getRules as $rule)
        $rules = $SalesRule->load($rule->getId());
        $item->setProduct($product);
        $validate = $rules->getActions()->validate($product);
        if ($validate == true)

        echo "coupon -".$rule->getCode()."'>".$rule->getCode()." - ".$rule->getDescription()." coupon";
        echo "<br>";
        # code...
        else
        continue;








        share|improve this answer













        I have created block to get cart items using checkout session file name is CustomSession.php



        protected $_checkoutSession;

        public function __construct (
        MagentoCheckoutModelSession $_checkoutSession
        )
        $this->_checkoutSession = $_checkoutSession;


        public function getProducts()

        $item = $this->_checkoutSession->getQuote()->getAllVisibleItems();
        return $item;



        than overriding the coupon.phtml file



         $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $objectManager->create('MagentoCatalogModelSession');
        $objectManager->create('MagentoCatalogModelSession');
        $CatalogSession = $objectManager->get('MagentoCatalogModelSession');
        $blockObj= $block->getLayout()->createBlock('SatishContactBlockCustomSession');
        $SalesRule = $objectManager->create('MagentoSalesRuleModelRule');
        $getRules = $SalesRule->getCollection();
        $item = $objectManager->create('MagentoCatalogModelProduct');

        $products = $blockObj->getProducts(); // this will also work using custom session block
        foreach ($products as $product)
        foreach ($getRules as $rule)
        $rules = $SalesRule->load($rule->getId());
        $item->setProduct($product);
        $validate = $rules->getActions()->validate($product);
        if ($validate == true)

        echo "coupon -".$rule->getCode()."'>".$rule->getCode()." - ".$rule->getDescription()." coupon";
        echo "<br>";
        # code...
        else
        continue;









        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        satishsatish

        16912




        16912



























            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%2f268875%2fhow-to-get-all-coupon-code-which-can-apply-on-cart-page-in-magento-2%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

            419 nièngy_Soadمي 19bal1.5o_g

            Queiggey Chernihivv 9NnOo i Zw X QqKk LpB