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;
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
add a comment |
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
I want to show list of valid coupon on cart page
– satish
Apr 5 at 8:38
add a comment |
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
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
magento2 coupon-codes
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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;
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
add a comment |
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;
add a comment |
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;
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;
edited 11 mins ago
answered Apr 6 at 8:01
satishsatish
16912
16912
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
I want to show list of valid coupon on cart page
– satish
Apr 5 at 8:38