husseycoding / ajaxcartpopup

3 stars 11 forks source link

How to integrate your mini cart?‏ #21

Closed pepe95270 closed 8 years ago

pepe95270 commented 8 years ago

Hi, I'm using your Ajax Cart Popup extension (thank you for that by the way) but it's seems that your minicart is overridden by my custom theme. Do you know how can I solve that?

Thank you so much, Pierre Flamant

husseycoding commented 8 years ago

Hi Pierre, if you have another extension/customisation that is adding a mini cart popup (which you have) you need to disable it if you want to use Ajax Cart Popup - it's not designed to work along side other similar functionality.

pepe95270 commented 8 years ago

Thanks for the answer, your are right I'm using a custom theme. But I tried using the rwd structure:

<a class="skip-link skip-cart  no-count" href="#header-cart">
    <span class="icon"></span>
    <span class="label">Cart</span>
    <span class="count">0</span>
</a>

But it didn't work, I'll try to look into your code to see we're your doing your anchor to the "top-link-cart" class... I'll keep you informed. If you think it's caused by something else let me know :)

husseycoding commented 8 years ago

The extension relies on an anchor element with class of either top-link-cart of skip-cart to position the mini cart popup - it will use the first element that meets this criteria it finds.

If you notice when you add a product to the cart it does show the correct cart popup, so it's functioning, it's just not in the right place. I believe the problem in your case is because you have both of the above elements on the page - skip-cart at the top, and top-link-cart beneath the 'swipe' element. You might find it sufficient to just rename the top-link-cart class to something else.

pepe95270 commented 8 years ago

Yes, I changed all the ancient "skip-cart" and "top-link-cart" class to something else and named my mini cart with a class="top-link-cart" but it doesn't seems to find it... Is there another condition in order to anchor the popup to the mini-cart?

Thanks you

pepe95270 commented 8 years ago

Ok, I've checked your javascript file and found that there has to be an <a> tag for the popup to be anchored. So now the popup appear on the right place but the number of product isn't actualised well. I'll keep looking into it...

pepe95270 commented 8 years ago

I've inspected your javascript but I can't find where you are updating the "count" of the minicart. I see you get the element with the function "getCartElement", then sometimes you get the count with "this.getCartElement().down("span.count")" but you never update it... Could you tell me where do you update the count pls :) thank you in advance, Pierre Flamant

husseycoding commented 8 years ago

The count is updated by rendering the header cart link text here and then sent in the add to cart response. JS then updates the header cart element with this text here.

pepe95270 commented 8 years ago

I finaly succeded updating the cart :) I had another problem, the "delete" link from the mini cart was invalid, I had to add , 'form_key' => Mage::getSingleton('core/session')->getFormKey() in the function getDeleteUrl($itemid) of Popup.php public function getDeleteUrl($itemid) { return Mage::getUrl('checkout/cart/delete', array('id' => $itemid, 'form_key' => Mage::getSingleton('core/session')->getFormKey(), Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getUrlHelper()->getEncodedUrl())); }

Thank you.

husseycoding commented 8 years ago

The latest version of the extension already includes logic to include the form key when deleting, see issue #17.

pepe95270 commented 8 years ago

Ohh didn't saw that, thank you :)

I solved all my problems except a last one: When I click on the mini-cart it go to a 404 page. It seems that it's caused by an observer on <a class="top-link-cart"> that execute this function: (function (e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)})

Do you know how can I do to solve this?

Thank you very much :)

husseycoding commented 8 years ago

Does the link work without the extension enabled?

pepe95270 commented 8 years ago

Mmmm you are right, it's wasn't your extension's fault... Sorry for this mistake, my bad :) I'll try to make the mini-cart responsive and I'll be king of the world ;)

Bye, thank you again

husseycoding commented 8 years ago

Well done for getting it working!