Question

i have been working trying to create an edit order system where when an order is bellow a given state the customer can edit the order

now i have everything working by adding a reorder like link which does the exact same as reorder but creates a session which identifies that your editing an order, in order to do this for out of stock products i had to turn backorders on

however i have found a glitch, if a customer was to add 5 hats to the cart and logs off, if when they come back the item's stock qty is now 0 they can still go into the cart, naturally this is because of the backorders being enabled.

i have made a CartController to pick up adding/updates to the shopping cart and manually check if the stock is less than what's in the cart, however if the customer had the item when there was ample stock, leave and returns when it's now out of stock, they bypass these checks

one suggestion that was made by a college was that we shorten the lifetime of the cart session for registered customers, while we could do this, there is more of a problem during a sale

originally, before backorders was turned on, if this same situation occurred the "Proceed to checkout" button would be missing and you would get an error message

now i've tried fixing up a new IndexController and using $this->_getSession()->addError('Some products in your cart have gone out of stock'); but i'm not getting the same results

so how do i create an error message that will prevent the customer from going into the checkout until they have fixed up their cart

Was it helpful?

Solution

Try to add the error to the quote item.

    /app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php:300
    if ($baseMessages) {
        foreach ($baseMessages as $message) {
            $messages[] = array(
                'text' => $message,
                'type' => $quoteItem->getHasError() ? 'error' : 'notice'
            );
        }
    }

Might work. Just an idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top