1

Quite new to magento, and I search for a solution for the following

At this moment if there are no products in shopping cart the checkout button is disabled and user can not click on it.

if products already exist in shopping cart then on click redirect to /checkout/cart/ and show checkout form.

Now I would like to enable checkout form even on empty cart and show to the user that is nothing has been added to the cart so the ceckout form would have 0 products

the actual code looks like

public function cartCheck(Varien_Event_Observer $observer)
{
    try {
        $cart = Mage::getSingleton('checkout/cart');
        $quote = $cart->getQuote();



            // checks all quote items (coupon or free) for max quantity of 1
            foreach ($quoteItems as $quoteItem) {
                if ($quoteItem->getQty() > 1
                    && in_array(($quoteItem->getProduct()->getAttributeSetId()), array_keys($this->_maxQtyByAttributeSet))
                ) {
                    $this->addMessage(Mage::helper('cartrules')->__(
                        'The maximum quantity for %s is %d.',
                        $quoteItem->getProduct()->getName(),
                        1
                    ));
                    $quoteItem->setQty(1);
                    $quoteItem->getQuote()->save();
                }
            }
        }
        // no products in cart ... redirect to front page
        else {
            Mage::getSingleton('checkout/session')->addNotice(Mage::helper('cartrules')->__('Your shopping cart is empty.'));

            Mage::app()->getResponse()->setRedirect('/')->sendHeaders();
            exit;
        }
    } catch (Exception $e) {}
}
  • plz check using Mage::app()->getResponse()->setRedirect('checkout/onepage')->sendHeaders(); in above code of else part. – Rakesh Jesadiya Nov 19 '15 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.