How to add condition in add-to-cart button function? Magento 1.9How to do selected single product should be purchase alone?PHP else: statements in addtocart.phtml - Adding conditions to the Add To Cart button on product pageMagento 2 add to cart button validationCustomise “add to cart” buttonHow to exclude products being added to cart based on products attributes?How can I get the product details (like SKU) on JS when “Add to Cart” button is clicked?How can i give condition Shopping Cart Price Rules like if selected attribute products present in the cart, no other products allowed to add cartHow can i show USPS Media Mail Only For Books not for other Products?Change add to cart button based on customer groupHow to customize Add to cart functionality based on product categories in Magento 2?How to do selected single product should be purchase alone?
How can I smooth the top side of this ring?
What is the meaning of "it" in "as luck would have it"?
Is there a connection between representation theory and PDEs?
Reaction mechanism of rearrangement
Existence of infinite set of positive integers s.t sum of reciprocals is rational and set of primes dividing an element is infinite
Advantages of using bra-ket notation
Sentences with no verb, but an ablative
What prevents a US state from colonizing a smaller state?
SQL Server Ignoring Instance name when using port number of different instance
GFCI versus circuit breaker
Finding an optimal set without forbidden subsets
Can combing bent evaporator coil fins damage it?
Why is my 401k manager recommending me to save more?
Odd PCB Layout for Voltage Regulator
Wings for orbital transfer bioships?
Is it OK to say "The situation is pregnant with a crisis"?
How far can gerrymandering go?
Does the Grothendieck group of finitely generated modules form a commutative ring where the multiplication structure is induced from tensor product?
What does this Pokemon Trainer mean by saying the player is "SHELLOS"?
Confusion in understanding the behavior of inductor in RL circuit with DC source
How to extract coefficients of a generating function like this one, using a computer?
Variable declaration inside main loop
How soon after takeoff can you recline your airplane seat?
Why is quantum gravity non-renormalizable?
How to add condition in add-to-cart button function? Magento 1.9
How to do selected single product should be purchase alone?PHP else: statements in addtocart.phtml - Adding conditions to the Add To Cart button on product pageMagento 2 add to cart button validationCustomise “add to cart” buttonHow to exclude products being added to cart based on products attributes?How can I get the product details (like SKU) on JS when “Add to Cart” button is clicked?How can i give condition Shopping Cart Price Rules like if selected attribute products present in the cart, no other products allowed to add cartHow can i show USPS Media Mail Only For Books not for other Products?Change add to cart button based on customer groupHow to customize Add to cart functionality based on product categories in Magento 2?How to do selected single product should be purchase alone?
How to Add PHP script in add-to-cart function like if other products are trying to add add-to-cart, supposed selected id based products[restricted products] already available in add-to-cart here restrict and show message like not allowed to add-to-cart, please purchase alone, if already some other products available in cart condition like you need to purchase this product alone.
Using Magento add-to-cart button Function how to achieve my above condition?
magento-1.9 addtocart restriction
add a comment |
How to Add PHP script in add-to-cart function like if other products are trying to add add-to-cart, supposed selected id based products[restricted products] already available in add-to-cart here restrict and show message like not allowed to add-to-cart, please purchase alone, if already some other products available in cart condition like you need to purchase this product alone.
Using Magento add-to-cart button Function how to achieve my above condition?
magento-1.9 addtocart restriction
magento.stackexchange.com/questions/279094/…
– Ketan Borada
Jun 24 at 9:40
add a comment |
How to Add PHP script in add-to-cart function like if other products are trying to add add-to-cart, supposed selected id based products[restricted products] already available in add-to-cart here restrict and show message like not allowed to add-to-cart, please purchase alone, if already some other products available in cart condition like you need to purchase this product alone.
Using Magento add-to-cart button Function how to achieve my above condition?
magento-1.9 addtocart restriction
How to Add PHP script in add-to-cart function like if other products are trying to add add-to-cart, supposed selected id based products[restricted products] already available in add-to-cart here restrict and show message like not allowed to add-to-cart, please purchase alone, if already some other products available in cart condition like you need to purchase this product alone.
Using Magento add-to-cart button Function how to achieve my above condition?
magento-1.9 addtocart restriction
magento-1.9 addtocart restriction
edited Jun 24 at 8:51
Asad Khan
6881 silver badge17 bronze badges
6881 silver badge17 bronze badges
asked Jun 24 at 8:49
zuszus
301 silver badge20 bronze badges
301 silver badge20 bronze badges
magento.stackexchange.com/questions/279094/…
– Ketan Borada
Jun 24 at 9:40
add a comment |
magento.stackexchange.com/questions/279094/…
– Ketan Borada
Jun 24 at 9:40
magento.stackexchange.com/questions/279094/…
– Ketan Borada
Jun 24 at 9:40
magento.stackexchange.com/questions/279094/…
– Ketan Borada
Jun 24 at 9:40
add a comment |
1 Answer
1
active
oldest
votes
Create an event observer for event sales_quote_merge_before. Create a custom module and put this in config.xml.
<events>
<sales_quote_merge_before>
<observers>
<cart_validation>
<class>MyModule_CartValidation_Model_Observer</class>
<method>quoteMergeBefore</method>
</cart_update>
</observers>
</sales_quote_merge_before>
</events>
Create Observer.php in [MyModule]/[CartValidation]/Model and put this code.
class MyModule_CartValidation_Model_Observer
public function quoteMergeBefore($observer)
// Get Existing Cart Items
$quoteItem = Mage::getSingleton('checkout/cart') - > getQuote() - > getItemsCollection();
//Get current product trying to be added
$product = Mage::getModel('catalog/product')
- > load(Mage::app() - > getRequest() - > getParam('product', 0));
/*
* Your code logic to see restricted items in cart
*
*/
$isRestricted = $this - > hasRestrictedItems($quoteItem, $product);
if ($isRestricted)
Mage::getSingleton("core/session") - > addError("You can not add this product");
return;
Make sure you implement your restricted products logic in hasRestrictedItems().
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
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%2f279362%2fhow-to-add-condition-in-add-to-cart-button-function-magento-1-9%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
Create an event observer for event sales_quote_merge_before. Create a custom module and put this in config.xml.
<events>
<sales_quote_merge_before>
<observers>
<cart_validation>
<class>MyModule_CartValidation_Model_Observer</class>
<method>quoteMergeBefore</method>
</cart_update>
</observers>
</sales_quote_merge_before>
</events>
Create Observer.php in [MyModule]/[CartValidation]/Model and put this code.
class MyModule_CartValidation_Model_Observer
public function quoteMergeBefore($observer)
// Get Existing Cart Items
$quoteItem = Mage::getSingleton('checkout/cart') - > getQuote() - > getItemsCollection();
//Get current product trying to be added
$product = Mage::getModel('catalog/product')
- > load(Mage::app() - > getRequest() - > getParam('product', 0));
/*
* Your code logic to see restricted items in cart
*
*/
$isRestricted = $this - > hasRestrictedItems($quoteItem, $product);
if ($isRestricted)
Mage::getSingleton("core/session") - > addError("You can not add this product");
return;
Make sure you implement your restricted products logic in hasRestrictedItems().
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
add a comment |
Create an event observer for event sales_quote_merge_before. Create a custom module and put this in config.xml.
<events>
<sales_quote_merge_before>
<observers>
<cart_validation>
<class>MyModule_CartValidation_Model_Observer</class>
<method>quoteMergeBefore</method>
</cart_update>
</observers>
</sales_quote_merge_before>
</events>
Create Observer.php in [MyModule]/[CartValidation]/Model and put this code.
class MyModule_CartValidation_Model_Observer
public function quoteMergeBefore($observer)
// Get Existing Cart Items
$quoteItem = Mage::getSingleton('checkout/cart') - > getQuote() - > getItemsCollection();
//Get current product trying to be added
$product = Mage::getModel('catalog/product')
- > load(Mage::app() - > getRequest() - > getParam('product', 0));
/*
* Your code logic to see restricted items in cart
*
*/
$isRestricted = $this - > hasRestrictedItems($quoteItem, $product);
if ($isRestricted)
Mage::getSingleton("core/session") - > addError("You can not add this product");
return;
Make sure you implement your restricted products logic in hasRestrictedItems().
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
add a comment |
Create an event observer for event sales_quote_merge_before. Create a custom module and put this in config.xml.
<events>
<sales_quote_merge_before>
<observers>
<cart_validation>
<class>MyModule_CartValidation_Model_Observer</class>
<method>quoteMergeBefore</method>
</cart_update>
</observers>
</sales_quote_merge_before>
</events>
Create Observer.php in [MyModule]/[CartValidation]/Model and put this code.
class MyModule_CartValidation_Model_Observer
public function quoteMergeBefore($observer)
// Get Existing Cart Items
$quoteItem = Mage::getSingleton('checkout/cart') - > getQuote() - > getItemsCollection();
//Get current product trying to be added
$product = Mage::getModel('catalog/product')
- > load(Mage::app() - > getRequest() - > getParam('product', 0));
/*
* Your code logic to see restricted items in cart
*
*/
$isRestricted = $this - > hasRestrictedItems($quoteItem, $product);
if ($isRestricted)
Mage::getSingleton("core/session") - > addError("You can not add this product");
return;
Make sure you implement your restricted products logic in hasRestrictedItems().
Create an event observer for event sales_quote_merge_before. Create a custom module and put this in config.xml.
<events>
<sales_quote_merge_before>
<observers>
<cart_validation>
<class>MyModule_CartValidation_Model_Observer</class>
<method>quoteMergeBefore</method>
</cart_update>
</observers>
</sales_quote_merge_before>
</events>
Create Observer.php in [MyModule]/[CartValidation]/Model and put this code.
class MyModule_CartValidation_Model_Observer
public function quoteMergeBefore($observer)
// Get Existing Cart Items
$quoteItem = Mage::getSingleton('checkout/cart') - > getQuote() - > getItemsCollection();
//Get current product trying to be added
$product = Mage::getModel('catalog/product')
- > load(Mage::app() - > getRequest() - > getParam('product', 0));
/*
* Your code logic to see restricted items in cart
*
*/
$isRestricted = $this - > hasRestrictedItems($quoteItem, $product);
if ($isRestricted)
Mage::getSingleton("core/session") - > addError("You can not add this product");
return;
Make sure you implement your restricted products logic in hasRestrictedItems().
answered Jun 24 at 10:29
Abdul PathanAbdul Pathan
1637 bronze badges
1637 bronze badges
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
add a comment |
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
Join with chat.stackexchange.com/rooms/95367/…
– zus
Jun 25 at 5:27
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%2f279362%2fhow-to-add-condition-in-add-to-cart-button-function-magento-1-9%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
magento.stackexchange.com/questions/279094/…
– Ketan Borada
Jun 24 at 9:40