cancel
Showing results for 
Search instead for 
Did you mean: 

Inventory Rules based on Attribute Set

Inventory Rules based on Attribute Set

I am trying to find a way to set inventory rules based on an items attribute set.

 

For example, most of my products a customer can order as small as 1/4. But some items I want them to be forced to go incrementally starting at 1. So I want a way to where if the item is attribute X, those items are forced to be incremental with the inventory rules.

 

Is there a way to do this without setting each item's rules?

2 REPLIES 2

Re: Inventory Rules based on Attribute Set

So now I am trying to do this a different way.

 

Put an If statement checking whether the 'Enable Qty Increments' setting is enabled or not for an item and adding an increment/decrement button to it. The location for this is the addtocart.phtml

 

 <?php if ($this->getEnableQtyIncrements()): ?>
                <div class="qty-changer">
                    <a href="javascript&colon;void(0)" class="qty-inc"><i class="porto-icon-up-dir"></i></a>
                    <a href="javascript&colon;void(0)" class="qty-dec"><i class="porto-icon-down-dir"></i></a>
                </div>
            	<?php endif; ?>

This is what I think it should be, but it doesn't seem to be working properly so I am not sure what I am missing or if I have the wrong function call

Re: Inventory Rules based on Attribute Set

Took me a bit of digging to figure it out and find a solution but this is what I have come up with:

 

All of the following code is done in addtocart.phtml

 

Line 14 roughly

<?php $productHasIncrement = $_product->getExtensionAttributes()->getStockItem()->getQtyIncrements(); ?>

Lines 71-76 roughly

<?php if ($productHasIncrement > 0): ?>
                <div class="qty-changer">
                    <a href="javascript&colon;void(0)" class="qty-inc"><i class="porto-icon-up-dir"></i></a>
                    <a href="javascript&colon;void(0)" class="qty-dec"><i class="porto-icon-down-dir"></i></a>
                </div>
            	<?php endif; ?>