Originally Posted by
HeleneWallis
Thanks, that's what I needed. I don't need to know the quantity of any given product, only whether or not it's greater than 1. I have a very popular product which can be shipped by itself in a small flat rate box. But people keep ordering multiples of it and asking for that shipping method. I don't want to exclude it altogether, because that's the best shipping method for a single order. But every time someone orders more than one, I have to email them, explain that I can't ship it that way and ask for additional shipping costs. Wastes time and doesn't improve customer relations. This should take care of it.
Actually may be better to use the shopping_cart class function get_quantity($products_id) because it will return 0 if the product is not in the cart. All depends on how you are searching/referencing things...
Like if do a check like
Code:
if($_SESSION['cart']->in_cart('5')) {
if($_SESSION['cart']->contents['5']['qty'] > 1) {
//add extra shipping/disable option, etc...
}
}
Would work (though seemingly require more queries and effort than say:
Code:
if($_SESSION['cart']->get_quantity('5') > 1) {
//do shipping modification
}
That is also based on the description of needing/wanting to know if the quantity of a given product exceeds a limited number versus other checks that can be done to say identify the number of each item in the cart and take action based on that quantity regardless of which specific item it is, etc... I used '5' to represent the item in the store that has products_id of 5 and that the product does not have attributes. Once attributes get involved and if the attributes are not essential to your need to know the quantity (ie do not affect shipping) then you are better off using the function in my second post above. That will identify the quantity of the product in the cart where the attributes don't matter.
Bookmarks