0

As title suggests I am trying to get a cart-dropdown when product gets added to the basket. My files are set as below, please advice where could this possibly be going wrong as I can't get this to work. I am using Magento 1.9.4

/etc/config.xml

<?xml version="1.0"?>
<events>
<checkout_cart_product_add_after>
    <observers>
        <Namespace_TriggerName>
            <type>singleton</type>       
            <class>Namespace_TriggerName_Model_Observer</class>
            <method>opencartafteradd</method>
        </Namespace_TriggerName>
    </observers>
</checkout_cart_product_add_after>
</events>

/Model/Observer.php

<?php

class Namespace_TriggerName_Model_Observer
{
public function opencartafteradd($observer) {
    $event = $observer->getEvent();
    $product = $event->getProduct(); 
    Mage::getSingleton('core/session')->setOpenMinicart('ON');
 }
}

/app/design/frontend/theme/default/template/page/html/head.phtml

<script type="text/javascript">
var $v = jQuery.noConflict();
$v(document).ready(function() {
    var screen_width = $v(window).width();
    var openminicart = '<?php echo Mage::getSingleton('core/session')->getOpenMinicart();?>';
    if (screen_width > 780) {
        if (openminicart == 'ON') {
                jQuery("#header-cart").slideToggle('slow');
                jQuery("#header-cart").addClass('skip-active');


                setTimeout(function() {
                    jQuery("#header-cart").slideUp('fast');
                    $k('#header-cart').removeClass('skip-active');
                }, 4000);


        <?php Mage::getSingleton('core/session')->unsOpenMinicart();?>

        }
    }
});
</script>

1 Answer 1

0

Scrip code as below:

<script type="text/javascript">
var $v = jQuery.noConflict();
$v(document).ready(function() {
    var screen_width = $v(window).width();
    var openminicart = '<?php echo Mage::getSingleton('core/session')->getOpenMinicart();?>';
    if (screen_width > 780) {
        if (openminicart == 'ON') {
                $v("#header-cart").slideToggle('slow');
                $v("#header-cart").addClass('skip-active');


                setTimeout(function() {
                    $v("#header-cart").slideUp('fast');
                    $v('#header-cart').removeClass('skip-active');
                }, 4000);


        <?php Mage::getSingleton('core/session')->unsOpenMinicart();?>

        }
    }
});
</script>

$k instead of $v simple typo mistake

1
  • Am still not seeing any results, on when inspecting the JS element the openminicart variable is empty? Could there be a different session query?
    – pasujemito
    Apr 12, 2016 at 8:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.