Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back ordered products in cart verification do not check Manage Stock attribute #65

Open
FredericMartinez opened this issue Jul 22, 2019 · 0 comments

Comments

@FredericMartinez
Copy link
Contributor

In app/code/community/Affirm/Affirm/Helper/Data.php you don't check if every product in quote have Manage Stock active or not.

So even if a product has Manage Stock to Yes but behind the woods has also Backorders to Allow Qty Below 0, Affirm will be disabled.

<?php
// line 149

/**
 * Skip promo message for back ordered products cart
 *
 * @param null $quote
 * @return bool
 */
public function isDisableQuoteBackOrdered($quote = null)
{
    if (null === $this->_disabledBackOrderedCart) {
        if (!Mage::helper('affirm')->isDisableForBackOrderedItems()) {
            $this->_disabledBackOrderedCart = false;
            return $this->_disabledBackOrderedCart;
        }
        if (null === $quote) {
            $quote = Mage::helper('checkout/cart')->getQuote();
        }
        foreach ($quote->getAllItems() as $quoteItem) {
            $inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($quoteItem->getProduct());
            if ($inventory->getBackorders() && (($inventory->getQty() - $quoteItem->getQty()) < 0)) {
                $this->_disabledBackOrderedCart = true;
                break;
            }
        }
        Mage::register('affirm_disabled_backordered', $this->_disabledBackOrderedCart);
    }
    return $this->_disabledBackOrderedCart;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant