Skip to main content
added 18 characters in body; edited tags
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 25
  • 82

Created checkout_stop.xmlcheckout_stop.xml in app/etc/modulesapp/etc/modules with below code

Created config.xmlconfig.xml in app/code/local/Checkout/Stop/etcapp/code/local/Checkout/Stop/etc with below code

Created Observer.phpObserver.php in app/code/local/Checkout/Stop/Modelapp/code/local/Checkout/Stop/Model with below code

Created checkout_stop.xml in app/etc/modules with below code

Created config.xml in app/code/local/Checkout/Stop/etc with below code

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

Created checkout_stop.xml in app/etc/modules with below code

Created config.xml in app/code/local/Checkout/Stop/etc with below code

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

deleted 1 character in body
Source Link

As the title says. I need to be able to disable adding to cart if a product sku or shipping type already exists in the cart. Any way this can be done?

Created checkout_stop.xml in app/etc/modules with below code

<?xml version="1.0"?>
<config>
    <modules>
        <Checkout_Stop>
            <codePool>local</codePool>
            <active>false<<active>true</active>
        </Checkout_Stop>
    </modules>
</config>

Created config.xml in app/code/local/Checkout/Stop/etc with below code

<?xml version="1.0"?>
<config>
<modules>
    <Checkout_Stop>
        <version>0.1.0</version>
    </Checkout_Stop>
</modules>
<global>
    <models>
        <checkout_stop>
            <class>checkout_stop_Model</class>
        </checkout_stop>
    </models>
    <events>
        <checkout_cart_product_add_after>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>addtocartEvent</method>
                </checkout_stop_Model_Observer>
            </observers>
        </checkout_cart_product_add_after>
          
         <review_save_before>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>autoApproveReview</method>
                </checkout_stop_Model_Observer>
            </observers>
        </review_save_before>
    </events>
</global>

</config>

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

<?php

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach ($items as $item){
    if ($item->getSku() == 'shoes1001'){
        Mage::throwException(Mage::helper('checkout')->__('You cannot add that product to your cart');
    }
}
?> 

As the title says. I need to be able to disable adding to cart if a product sku or shipping type already exists in the cart. Any way this can be done?

Created checkout_stop.xml in app/etc/modules with below code

<?xml version="1.0"?>
<config>
    <modules>
        <Checkout_Stop>
            <codePool>local</codePool>
            <active>false</active>
        </Checkout_Stop>
    </modules>
</config>

Created config.xml in app/code/local/Checkout/Stop/etc with below code

<?xml version="1.0"?>
<config>
<modules>
    <Checkout_Stop>
        <version>0.1.0</version>
    </Checkout_Stop>
</modules>
<global>
    <models>
        <checkout_stop>
            <class>checkout_stop_Model</class>
        </checkout_stop>
    </models>
    <events>
        <checkout_cart_product_add_after>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>addtocartEvent</method>
                </checkout_stop_Model_Observer>
            </observers>
        </checkout_cart_product_add_after>
          
         <review_save_before>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>autoApproveReview</method>
                </checkout_stop_Model_Observer>
            </observers>
        </review_save_before>
    </events>
</global>

</config>

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

<?php

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach ($items as $item){
    if ($item->getSku() == 'shoes1001'){
        Mage::throwException(Mage::helper('checkout')->__('You cannot add that product to your cart');
    }
}
?> 

As the title says. I need to be able to disable adding to cart if a product sku or shipping type already exists in the cart. Any way this can be done?

Created checkout_stop.xml in app/etc/modules with below code

<?xml version="1.0"?>
<config>
    <modules>
        <Checkout_Stop>
            <codePool>local</codePool>
            <active>true</active>
        </Checkout_Stop>
    </modules>
</config>

Created config.xml in app/code/local/Checkout/Stop/etc with below code

<?xml version="1.0"?>
<config>
<modules>
    <Checkout_Stop>
        <version>0.1.0</version>
    </Checkout_Stop>
</modules>
<global>
    <models>
        <checkout_stop>
            <class>checkout_stop_Model</class>
        </checkout_stop>
    </models>
    <events>
        <checkout_cart_product_add_after>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>addtocartEvent</method>
                </checkout_stop_Model_Observer>
            </observers>
        </checkout_cart_product_add_after>
          
         <review_save_before>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>autoApproveReview</method>
                </checkout_stop_Model_Observer>
            </observers>
        </review_save_before>
    </events>
</global>

</config>

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

<?php

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach ($items as $item){
    if ($item->getSku() == 'shoes1001'){
        Mage::throwException(Mage::helper('checkout')->__('You cannot add that product to your cart');
    }
}
?> 
Added current non working code
Source Link

As the title says. I need to be able to disable adding to cart if a product sku or shipping type already exists in the cart. Any way this can be done?

Created checkout_stop.xml in app/etc/modules with below code

<?xml version="1.0"?>
<config>
    <modules>
        <Checkout_Stop>
            <codePool>local</codePool>
            <active>false</active>
        </Checkout_Stop>
    </modules>
</config>

Created config.xml in app/code/local/Checkout/Stop/etc with below code

<?xml version="1.0"?>
<config>
<modules>
    <Checkout_Stop>
        <version>0.1.0</version>
    </Checkout_Stop>
</modules>
<global>
    <models>
        <checkout_stop>
            <class>checkout_stop_Model</class>
        </checkout_stop>
    </models>
    <events>
        <checkout_cart_product_add_after>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>addtocartEvent</method>
                </checkout_stop_Model_Observer>
            </observers>
        </checkout_cart_product_add_after>
          
         <review_save_before>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>autoApproveReview</method>
                </checkout_stop_Model_Observer>
            </observers>
        </review_save_before>
    </events>
</global>

</config>

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

<?php

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach ($items as $item){
    if ($item->getSku() == 'shoes1001'){
        Mage::throwException(Mage::helper('checkout')->__('You cannot add that product to your cart');
    }
}
?> 

As the title says. I need to be able to disable adding to cart if a product sku or shipping type already exists in the cart. Any way this can be done?

As the title says. I need to be able to disable adding to cart if a product sku or shipping type already exists in the cart. Any way this can be done?

Created checkout_stop.xml in app/etc/modules with below code

<?xml version="1.0"?>
<config>
    <modules>
        <Checkout_Stop>
            <codePool>local</codePool>
            <active>false</active>
        </Checkout_Stop>
    </modules>
</config>

Created config.xml in app/code/local/Checkout/Stop/etc with below code

<?xml version="1.0"?>
<config>
<modules>
    <Checkout_Stop>
        <version>0.1.0</version>
    </Checkout_Stop>
</modules>
<global>
    <models>
        <checkout_stop>
            <class>checkout_stop_Model</class>
        </checkout_stop>
    </models>
    <events>
        <checkout_cart_product_add_after>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>addtocartEvent</method>
                </checkout_stop_Model_Observer>
            </observers>
        </checkout_cart_product_add_after>
          
         <review_save_before>
            <observers>
                <checkout_stop_Model_Observer>
                    <type>singleton</type>
                    <class>checkout_stop_Model_Observer</class>
                    <method>autoApproveReview</method>
                </checkout_stop_Model_Observer>
            </observers>
        </review_save_before>
    </events>
</global>

</config>

Created Observer.php in app/code/local/Checkout/Stop/Model with below code

<?php

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach ($items as $item){
    if ($item->getSku() == 'shoes1001'){
        Mage::throwException(Mage::helper('checkout')->__('You cannot add that product to your cart');
    }
}
?> 
Tweeted twitter.com/StackMagento/status/838706087121588224
Source Link
Loading