Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Number of articles in basket divisable by 6
 
medienagenten
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

Hi.

I want to constrain the checkout so that all items in the basket add up to an amount divisable by 6. This is due to packaging-limitations.

It would be ok to buy 5 x article A and 1 x article B (=6)
but not
6 x article A and 2 x article B (=8)

Can this be done?
Thanks for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
kullysupply
Member
 
Avatar
Total Posts:  48
Joined:  2008-08-05
 

You could try this:

In the file app/design/frontend/*/*/template/checkout/cart.phtml, make the follow change:

<div class="totals">
        
<?php echo $this->getChildHtml('totals'); ?>
        <?php 
if(!$this->hasError()): ?>
        
<ul class="checkout-types">
            
<?php if(Mage::getSingleton('checkout/cart')->getSummaryQty()%== 0): ?>
                <?php 
echo $this->getChildHtml('methods'?>
            <?php 
else: ?>
                Total items must be divisible by 6
            <?php 
endif; ?>
        
</ul>
        
<?php endif; ?>
    
</div>

This seemed to work for me. The checkout buttons are removed from the cart page if the total items are not divisible by 6. Is this what you were looking for?

 
Magento Community Magento Community
Magento Community
Magento Community
 
medienagenten
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

Wow.
Worked perfectly! Thanks!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

@ kullysupply

I’m dying to know if i can take the rule that you have used and implement it instead of %6 but to say there can’t be anymore than 2 articles in the basket…

elfling

 
Magento Community Magento Community
Magento Community
Magento Community
 
medienagenten
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

Assuming that getSummaryQty() holds the number of articles in the basket, I’d guess that this should work:

<?php if(Mage::getSingleton('checkout/cart')->getSummaryQty() < 2): ?>

right?

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

@ medienagenten

LEGEND!!!

Was almost what you said.

<?php if(Mage::getSingleton('checkout/cart')->getSummaryQty() < 3): ?>

Just a 3 instead of the two in order to restrict the basket to only 2 items or less.

THANKS THOUGH!!

Also, I commented out the top checkout button, because it remained, meh, as long as they can checkout.

 
Magento Community Magento Community
Magento Community
Magento Community
 
medienagenten
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

Hey Elfing.

You’ll also have to find the position in the mini-basket and add the same code. There is a “Checkout” button in the mini-basket that will skip the basket-view…

Cheers. Jochen

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

Where abouts is the code i need to fiddle with for the checkout mini basket?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top