how to get all coupon code which can apply on cart page in magento 2 The 2019 Stack Overflow Developer Survey Results Are InHow 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?

Worn-tile Scrabble

Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?

Mathematics of imaging the black hole

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Why not take a picture of a closer black hole?

Is it safe to harvest rainwater that fell on solar panels?

A word that means fill it to the required quantity

Did any laptop computers have a built-in 5 1/4 inch floppy drive?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

How to add class in ko template in magento2

What is the most efficient way to store a numeric range?

Short story: child made less intelligent and less attractive

What is the motivation for a law requiring 2 parties to consent for recording a conversation

Geography at the pixel level

Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past

Short story: man watches girlfriend's spaceship entering a 'black hole' (?) forever

Dropping list elements from nested list after evaluation

Falsification in Math vs Science

Why does the nucleus not repel itself?

How to type a long/em dash `—`

"as much details as you can remember"

Why doesn't UInt have a toDouble()?



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



The 2019 Stack Overflow Developer Survey Results Are InHow 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('VendorContactBlockCustomSession');
$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('VendorContactBlockCustomSession');
    $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('VendorContactBlockCustomSession');
      $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('VendorContactBlockCustomSession');
        $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('VendorContactBlockCustomSession');
        $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








        edited 11 mins ago

























        answered Apr 6 at 8:01









        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

            منجزی محتویات تیره‌های طایفه منجزی[ویرایش] مشاهیر طایفه منجزی[ویرایش] محل سکونت[ویرایش] پانویس[ویرایش] منابع[ویرایش] منوی ناوبری«نمودار اجتماعی طوایف بختیاری»«BakhtyārBAḴTĪĀRĪ TRIBE»«اسامی طوایف و شعب ایل بختیاری»ووگسترش آن

            بیوانفورماتیک محتویات تاریخچه[ویرایش] اهداف[ویرایش] کاربردهای بیوانفورماتیک[ویرایش] زمینه‌های مهم بیوانفورماتیک[ویرایش] موضوعات سیستم نرم‌افزاری بیوانفورماتیک[ویرایش] مراکز و ابزار[ویرایش] جستارهای وابسته[ویرایش] پیوند به بیرون[ویرایش] منابع[ویرایش] منوی ناوبریووانجمن بیوانفورماتیک ایرانمرکز بیوانفورماتیک دانشگاه تهرانمرکز ملی تحقیقات بیوانفورماتیکانستیتو بیو-آی‌تیبانک داده‌های دی ان ایمرکز ملی اطلاعات بیوتکنولوژیانستیتوی بیوانفورماتیک اروپاپورتال بیوانفورماتیک ایران«فرهنگ واژه‌های مصوب فرهنگستان ـ دفتر هشتم، بخش لاتین»وووو4611085-900870420ووو