Magento 1.9 Programmatically removing promo items from cartRemove item from cartAlways display Shopping Cart...
Inventor that creates machine that grabs man from future
Do my Windows system binaries contain sensitive information?
What's the rationale behind the objections to these measures against human trafficking?
How Should I Define/Declare String Constants
How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?
Am I a Rude Number?
Do commercial flights continue with an engine out?
Word to be used for "standing with your toes pointing out"
Could quantum mechanics be necessary to analyze some biology scenarios?
Why is c4 a better move in this position?
How to properly claim credit for peer review?
How would an AI self awareness kill switch work?
Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?
Finding ratio of the area of triangles
Do authors have to be politically correct in article-writing?
Finding the number of integers that are a square and a cube at the same time
How to add multiple differently colored borders around a node?
How to approximate rolls for potions of healing using only d6's?
How to avoid being sexist when trying to employ someone to function in a very sexist environment?
I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?
Dilemma of explaining to interviewer that he is the reason for declining second interview
Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?
What is better: yes / no radio, or simple checkbox?
Is there a way to help users from having to clicking emails twice before logging into a new sandbox
Magento 1.9 Programmatically removing promo items from cart
Remove item from cartAlways display Shopping Cart Price Rules Label above cart (not just when rule is first applied)Magento shopping cart rule exclusion logicRemoving item from cart on Observer methodMagento buy 2 get one freeCart items will not be deleted in observerAddtocart problemRemoving Cart items - ObserverRemove wishlist items when added to cart
I have a controller that loops through all items in the cart, and removes the item if it matches the condition, in this case all products should be removed because of the true
as condition.
$cart = Mage::helper('checkout/cart')->getCart();
// Loop through products
foreach ($cart->getItems() as $item) {
if(true) { // Normally a different condition
$cart->removeItem($item->getItemId());
}
}
The script does remove all items, except for those added as promotional item by a module (Amasty Free Gifts / Promo Items).
The items unique key doesn't change, so it is not being removed from the cart, neither added again by the module, because the key hasn't changed.
When I delete the main item, the promo item came with, the promo item is deleted.
How can I delete this product?
magento-1.9 cart promotions
add a comment |
I have a controller that loops through all items in the cart, and removes the item if it matches the condition, in this case all products should be removed because of the true
as condition.
$cart = Mage::helper('checkout/cart')->getCart();
// Loop through products
foreach ($cart->getItems() as $item) {
if(true) { // Normally a different condition
$cart->removeItem($item->getItemId());
}
}
The script does remove all items, except for those added as promotional item by a module (Amasty Free Gifts / Promo Items).
The items unique key doesn't change, so it is not being removed from the cart, neither added again by the module, because the key hasn't changed.
When I delete the main item, the promo item came with, the promo item is deleted.
How can I delete this product?
magento-1.9 cart promotions
add a comment |
I have a controller that loops through all items in the cart, and removes the item if it matches the condition, in this case all products should be removed because of the true
as condition.
$cart = Mage::helper('checkout/cart')->getCart();
// Loop through products
foreach ($cart->getItems() as $item) {
if(true) { // Normally a different condition
$cart->removeItem($item->getItemId());
}
}
The script does remove all items, except for those added as promotional item by a module (Amasty Free Gifts / Promo Items).
The items unique key doesn't change, so it is not being removed from the cart, neither added again by the module, because the key hasn't changed.
When I delete the main item, the promo item came with, the promo item is deleted.
How can I delete this product?
magento-1.9 cart promotions
I have a controller that loops through all items in the cart, and removes the item if it matches the condition, in this case all products should be removed because of the true
as condition.
$cart = Mage::helper('checkout/cart')->getCart();
// Loop through products
foreach ($cart->getItems() as $item) {
if(true) { // Normally a different condition
$cart->removeItem($item->getItemId());
}
}
The script does remove all items, except for those added as promotional item by a module (Amasty Free Gifts / Promo Items).
The items unique key doesn't change, so it is not being removed from the cart, neither added again by the module, because the key hasn't changed.
When I delete the main item, the promo item came with, the promo item is deleted.
How can I delete this product?
magento-1.9 cart promotions
magento-1.9 cart promotions
edited 17 mins ago
Shoaib Munir
1,5421526
1,5421526
asked Jul 9 '18 at 10:03
J. MeijerJ. Meijer
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
if ($item->getProduct()->getSku() == 'promo') {
$cartHelper->getCart()->removeItem($item->getItemId())->save();
break;
}
}
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
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%2f232850%2fmagento-1-9-programmatically-removing-promo-items-from-cart%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
Try
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
if ($item->getProduct()->getSku() == 'promo') {
$cartHelper->getCart()->removeItem($item->getItemId())->save();
break;
}
}
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
add a comment |
Try
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
if ($item->getProduct()->getSku() == 'promo') {
$cartHelper->getCart()->removeItem($item->getItemId())->save();
break;
}
}
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
add a comment |
Try
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
if ($item->getProduct()->getSku() == 'promo') {
$cartHelper->getCart()->removeItem($item->getItemId())->save();
break;
}
}
Try
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
if ($item->getProduct()->getSku() == 'promo') {
$cartHelper->getCart()->removeItem($item->getItemId())->save();
break;
}
}
answered Jul 9 '18 at 10:10
Prashant PatelPrashant Patel
877314
877314
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
add a comment |
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
The removeItem() function isn't reached, there are no items with sku 'promo'.
– J. Meijer
Jul 9 '18 at 10:24
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%2f232850%2fmagento-1-9-programmatically-removing-promo-items-from-cart%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