Add Qty to Product before adding to cart The 2019 Stack Overflow Developer Survey Results Are InIs it possible to use an observer to add a checkout button after product has been added to shopping cart?Check Some Condition Before Product added to cartObserve product qty changes onlyDynamically add extra price on subtotal on cartadd product to cart and change price and weightAdd a product to cart without going through the event checkout_cart_product_add_afterhow to prevent a product be added to a cart?Magento Cart page update qty, check if product qty availableHow to add the same product twice in cart with different qty and 0 priceHow to get simple product qty via configurable using Observer?
Likelihood that a superbug or lethal virus could come from a landfill
Pokemon Turn Based battle (Python)
Why isn't the circumferential light around the M87 black hole's event horizon symmetric?
How come people say “Would of”?
Falsification in Math vs Science
How do you keep chess fun when your opponent constantly beats you?
I am an eight letter word. What am I?
What is this sharp, curved notch on my knife for?
Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?
What is this business jet?
How to obtain a position of last non-zero element
How to translate "being like"?
How did passengers keep warm on sail ships?
Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?
Why doesn't UInt have a toDouble()?
Is Cinnamon a desktop environment or a window manager? (Or both?)
How to charge AirPods to keep battery healthy?
Why is the maximum length of OpenWrt’s root password 8 characters?
Accepted by European university, rejected by all American ones I applied to? Possible reasons?
Getting crown tickets for Statue of Liberty
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
How much of the clove should I use when using big garlic heads?
How do PCB vias affect signal quality?
Worn-tile Scrabble
Add Qty to Product before adding to cart
The 2019 Stack Overflow Developer Survey Results Are InIs it possible to use an observer to add a checkout button after product has been added to shopping cart?Check Some Condition Before Product added to cartObserve product qty changes onlyDynamically add extra price on subtotal on cartadd product to cart and change price and weightAdd a product to cart without going through the event checkout_cart_product_add_afterhow to prevent a product be added to a cart?Magento Cart page update qty, check if product qty availableHow to add the same product twice in cart with different qty and 0 priceHow to get simple product qty via configurable using Observer?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am looking for an event observer which is suitable for my requirment.
My requirment is i add to cart the product but qty i want to add to this cart will be decided by the product attribute.
I will be having custom attribute called attribute1
which will have integer number.
So when I add to cart the product, I will get the attribute and number which is defined in it and i set this number as a qty to the product which is getting added to cart.
So following are the observers i tried, but not got any success
checkout_cart_product_add_after
and I am looking for event something like checkout_cart_product_add_before
but it seems not their.
Please help me.
magento-1.9 event-observer addtocart
add a comment |
I am looking for an event observer which is suitable for my requirment.
My requirment is i add to cart the product but qty i want to add to this cart will be decided by the product attribute.
I will be having custom attribute called attribute1
which will have integer number.
So when I add to cart the product, I will get the attribute and number which is defined in it and i set this number as a qty to the product which is getting added to cart.
So following are the observers i tried, but not got any success
checkout_cart_product_add_after
and I am looking for event something like checkout_cart_product_add_before
but it seems not their.
Please help me.
magento-1.9 event-observer addtocart
add a comment |
I am looking for an event observer which is suitable for my requirment.
My requirment is i add to cart the product but qty i want to add to this cart will be decided by the product attribute.
I will be having custom attribute called attribute1
which will have integer number.
So when I add to cart the product, I will get the attribute and number which is defined in it and i set this number as a qty to the product which is getting added to cart.
So following are the observers i tried, but not got any success
checkout_cart_product_add_after
and I am looking for event something like checkout_cart_product_add_before
but it seems not their.
Please help me.
magento-1.9 event-observer addtocart
I am looking for an event observer which is suitable for my requirment.
My requirment is i add to cart the product but qty i want to add to this cart will be decided by the product attribute.
I will be having custom attribute called attribute1
which will have integer number.
So when I add to cart the product, I will get the attribute and number which is defined in it and i set this number as a qty to the product which is getting added to cart.
So following are the observers i tried, but not got any success
checkout_cart_product_add_after
and I am looking for event something like checkout_cart_product_add_before
but it seems not their.
Please help me.
magento-1.9 event-observer addtocart
magento-1.9 event-observer addtocart
edited Jul 17 '17 at 21:14
sv3n
9,95162457
9,95162457
asked Jan 6 '16 at 10:02
Pradeep SankuPradeep Sanku
7,93113157
7,93113157
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
You could use the sales_quote_product_add_after
event. You can access there the added quote items and change the quantity. Just be careful not to change the quantity for items that have a parent set (you can check if $item->getParentItem()
is set).
add a comment |
I don't know the code you have used, but it works with checkout_cart_product_add_after
and set quantity on $strockItem
instead of $product
:
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
$product = $observer->getProduct();
$stockItem = $product->getStockItem();
$stockItem->setQty($product->getData('attribute1'));
$stockItem->save();
add a comment |
I would say that the best approach is using the min sale qty
this way the quantity added to the cart will be the value that you have set.
add a comment |
You can rewrite Mage_Checkout_CartController
or check if any third party module have rewrite Mage_Checkout_CartController
class already then use that class to rewrite,
In AddAction
function - get attribute1
value and setParam
qty
= attribute1
of getRequest
.
Then call - parent::AddAction();
- So that this wont break the original code of magento.
Did anyone find my answer useful or not? Because of -1 point I can't post answers and questions in other Stack Exchange websites. I'm completely frustrated & stuck because of this -1 point. Otherwise I will not come to any Stack Exchange sites any more.
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%2f96146%2fadd-qty-to-product-before-adding-to-cart%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use the sales_quote_product_add_after
event. You can access there the added quote items and change the quantity. Just be careful not to change the quantity for items that have a parent set (you can check if $item->getParentItem()
is set).
add a comment |
You could use the sales_quote_product_add_after
event. You can access there the added quote items and change the quantity. Just be careful not to change the quantity for items that have a parent set (you can check if $item->getParentItem()
is set).
add a comment |
You could use the sales_quote_product_add_after
event. You can access there the added quote items and change the quantity. Just be careful not to change the quantity for items that have a parent set (you can check if $item->getParentItem()
is set).
You could use the sales_quote_product_add_after
event. You can access there the added quote items and change the quantity. Just be careful not to change the quantity for items that have a parent set (you can check if $item->getParentItem()
is set).
answered Jan 16 '16 at 16:25
Marina VilceaMarina Vilcea
1,111514
1,111514
add a comment |
add a comment |
I don't know the code you have used, but it works with checkout_cart_product_add_after
and set quantity on $strockItem
instead of $product
:
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
$product = $observer->getProduct();
$stockItem = $product->getStockItem();
$stockItem->setQty($product->getData('attribute1'));
$stockItem->save();
add a comment |
I don't know the code you have used, but it works with checkout_cart_product_add_after
and set quantity on $strockItem
instead of $product
:
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
$product = $observer->getProduct();
$stockItem = $product->getStockItem();
$stockItem->setQty($product->getData('attribute1'));
$stockItem->save();
add a comment |
I don't know the code you have used, but it works with checkout_cart_product_add_after
and set quantity on $strockItem
instead of $product
:
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
$product = $observer->getProduct();
$stockItem = $product->getStockItem();
$stockItem->setQty($product->getData('attribute1'));
$stockItem->save();
I don't know the code you have used, but it works with checkout_cart_product_add_after
and set quantity on $strockItem
instead of $product
:
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
$product = $observer->getProduct();
$stockItem = $product->getStockItem();
$stockItem->setQty($product->getData('attribute1'));
$stockItem->save();
edited Jul 29 '17 at 19:19
answered Jul 17 '17 at 21:10
sv3nsv3n
9,95162457
9,95162457
add a comment |
add a comment |
I would say that the best approach is using the min sale qty
this way the quantity added to the cart will be the value that you have set.
add a comment |
I would say that the best approach is using the min sale qty
this way the quantity added to the cart will be the value that you have set.
add a comment |
I would say that the best approach is using the min sale qty
this way the quantity added to the cart will be the value that you have set.
I would say that the best approach is using the min sale qty
this way the quantity added to the cart will be the value that you have set.
edited May 5 '18 at 9:55
Teja Bhagavan Kollepara
2,98841949
2,98841949
answered Feb 21 '18 at 23:22
user63984
add a comment |
add a comment |
You can rewrite Mage_Checkout_CartController
or check if any third party module have rewrite Mage_Checkout_CartController
class already then use that class to rewrite,
In AddAction
function - get attribute1
value and setParam
qty
= attribute1
of getRequest
.
Then call - parent::AddAction();
- So that this wont break the original code of magento.
Did anyone find my answer useful or not? Because of -1 point I can't post answers and questions in other Stack Exchange websites. I'm completely frustrated & stuck because of this -1 point. Otherwise I will not come to any Stack Exchange sites any more.
add a comment |
You can rewrite Mage_Checkout_CartController
or check if any third party module have rewrite Mage_Checkout_CartController
class already then use that class to rewrite,
In AddAction
function - get attribute1
value and setParam
qty
= attribute1
of getRequest
.
Then call - parent::AddAction();
- So that this wont break the original code of magento.
Did anyone find my answer useful or not? Because of -1 point I can't post answers and questions in other Stack Exchange websites. I'm completely frustrated & stuck because of this -1 point. Otherwise I will not come to any Stack Exchange sites any more.
add a comment |
You can rewrite Mage_Checkout_CartController
or check if any third party module have rewrite Mage_Checkout_CartController
class already then use that class to rewrite,
In AddAction
function - get attribute1
value and setParam
qty
= attribute1
of getRequest
.
Then call - parent::AddAction();
- So that this wont break the original code of magento.
Did anyone find my answer useful or not? Because of -1 point I can't post answers and questions in other Stack Exchange websites. I'm completely frustrated & stuck because of this -1 point. Otherwise I will not come to any Stack Exchange sites any more.
You can rewrite Mage_Checkout_CartController
or check if any third party module have rewrite Mage_Checkout_CartController
class already then use that class to rewrite,
In AddAction
function - get attribute1
value and setParam
qty
= attribute1
of getRequest
.
Then call - parent::AddAction();
- So that this wont break the original code of magento.
Did anyone find my answer useful or not? Because of -1 point I can't post answers and questions in other Stack Exchange websites. I'm completely frustrated & stuck because of this -1 point. Otherwise I will not come to any Stack Exchange sites any more.
edited May 30 '18 at 16:54
answered Jun 17 '17 at 13:14
AnanthAnanth
524
524
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%2f96146%2fadd-qty-to-product-before-adding-to-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