Show $cartItemsCount for each Magento website ID - magento

I have a magento multistore website where we have a landing page that links to three stores (and each store is on it’s own subdomain). The carts/checkouts are all separate, but we have the customers set as global so they can navigate to each store without relogging in. We would like to show a summary block on the landing page that lists the 3 carts and the number of items in each, as simple as
Cart for Site A has 1 item
Cart for Site B is empty
Cart for Site C has 2 items
It seems like it should be simple, like:
$_cartQty = Mage::getSingleton('checkout/cart')->getItemsCount()
but I am having a terrible time finding any answers. Thanks!

Use
$count = $this->helper('checkout/cart')->getSummaryCount(); //get total items in cart
$total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price

Related

Codeigniter cart Library not working properly

I have used cart library for adding updating and deleting items in carts. I am counting number cart items not quantity. I am counting number of item in navigation header which will be including in all pages. But when i navigate to different pages cart item will not be the same. If i added 2 items in cart in home page it shows 2. when i navigate to about us page it it will automatically setting to 1. if i use cart count why it will display different count in different page? Help me with this.

Display current user's (number of) wishlist items in top links, on shared wishlist link

When a wishlist having some items, is shared with someone by email, and the invited user visits the link (assuming user is logged in already), the top wishlist link then shows then number of items in wishlist for that shared link rather then it should still show the current user's wishlist (number of) items.
E.g.
If I have my own wishlist maintained with 4 number of items.
Then one of my friend share with me link to see his wishlist with 12 number of items.
When I visit that link shared while I am logged in, I see in the number of items shown in wishlist toplink equals to 12
Whereas, it should still show 4 items in top wishlist link, as I am still logged in and I do have my own wishlist.
I did it myself after a lot of headbang :) Am posting the solution so another poor soul like me can take a breath.
Copy The file app/code/core/Mage/Wishlist/Helper/Data.php
Look for the function public function getItemCount() // around line 168 for me
Replace this line return $this->_getCustomerSession()->getWishlistItemCount();
With the code below:
if(Mage::registry('shared_wishlist') && $this->_isCustomerLogIn()){
$customer = $this->getCustomer();
$wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true);
$wishListItemCollection = $wishlist->getItemCollection();
return count($wishListItemCollection);
}
else{
return $this->_getCustomerSession()->getWishlistItemCount();
}
//return $this->_getCustomerSession()->getWishlistItemCount();
And now you will always see current customer wishlist items in toplinks (wishlist link in header), no matter what.
Cheers!
I had this same problem, but fixed by changing the option Display Wishlist Summary to Display Item quantities.

Magento change quote/cart total after add product to cart

I have a scenario that when the customer adds products to the cart I will free 1 qty of minimum item (almost like salesrule "buy x get y"). So, I need to change the quote total after the products have been added to the cart.
I tried several events: checkout_cart_product_add_after, checkout_cart_add_product_complete, sales_quote_collect_totals_after... and when I change the quotes total and log right that time, the total has changed, but when I go to shopping cart page, it is unchanged.
I tried getting the quote by: $observer->getEvent()->getQuote(), or $session->getQuote() and also collected quote total again, but nothing happened.
Is there any way to change the quote/cart's total right after adding products to the cart (or cartView action)???

magento add minimum buyable qty from category listing

I have this situation where for all products in the store I have set a minimum of 50 products for a user to buy. This works fine when the user goes to the detail page and adds the product in cart, however if he pushes the button from category listing there is only 1 product added.
This triggers an error in the checkout making the user to increase the amount of products in the current basket.
Is there any way I can make the system add to cart 50 products at once if the user is adding from category listing page?
Magento is 1.5 CE.
If Add to Cart Url of Product at listing has qty parameter then it will directly add product to cart with given quantity like http://domain/index.php/checkout/cart/add/uenc/###/product/17/form_key/###/qty/50/
In {theme}template/catalog/product/list.phtml
<?php echo $this->getAddToCartUrl($_product,array('qty'=>$_minimalQty)) ?>
will do this trik.
Now to get minimum sale quantity at listing page you can follow this answer

Limit cart to 1 product per attribute/type - Magento

Our company sells pharmaceuticals online and by law we are limited to how much of a particular drug a customer can purchase.
For singular products with one brand this is easily controllable through default Magento functionality, my problem arises when we have different brands of a particular drug.
In a nutshell I can currently limit a customer to 1 pack of paracetamol from brand A but there is nothing to stop them getting another pack from brand B at the same time.
I would like to be able to check the cart for products with a particular attribute and limit them to 1 per cart. Ideally this would be when the customer clicks add to cart and the message would be displayed via the default Magento alerts that we currently have.
EDIT: I think the easiest way to solve this would be to check the SKU codes currently in the basket when adding a product to the cart. If there is a match, Throw up an error else add the item to the cart.
I think this link will help you but you need to modify as per your requirement. http://ceckoslab.com/magento/magento-check-if-product-is-in-cart/..
This link is to check the cart whether the same product is added or not? So modify this as per you requirement
You can set maximum allowed quantity in cart from admin panel. System->configuration. From left tab see catalog->inventory. Set Maximum qty allowed in shopping cart to 1.
If you want to add check on whole cart. see this paid extension

Resources