Getting Reorder to ignore stock levels in magento - php

i've been tasked to create a system where a customer can edit an order before it reaches the processing stage, i figure that the easiest way is to use the cart but with some edits to it to detect that your editing the order rather than making a new one
i have been testing out theories so far and everything seem to pan out, on theory i have been trying to get to work is utilizing the same process for re-ordering to populate the cart with the previous order, however i've ran into a problem, if an item is out of stock, it wont be added and until the customer confirms the changed to their order, i can go and release what they ordered, i can store how much the customer ordered but only if the item is added to the cart
so is there a way to get magento to add items to the cart with the re-order while ignoring what stock levels are
EDIT:
i've tried removing the Try Catch in Mage_Sales_Controller_Abstract in the function reorderAction() and it's adding the items however this means also i can't catch the exception of it's if it's just a notice or if there is any other reason why it can't add the item to the cart besides not having the stock

Got it working now, the trick was to enable Backorders and also modify parts of magento to prevent sellers from exceeding stock levels when they normally order (since if an item only has 6 in stock, with backorders enabled a customer can buy 10), after that it was simply setting up a system in the cart to detect when your editing an order and only allow backordering there since all orders are checked in the warehouse

Related

In Woo I need real stock levels to decrease when order is created and don't decrease until order cancel

I need a product stock to decrease immediately on order creation and it should not increase unless the order is cancelled (it should also not decrease a second time upon payment successful or any other switch).
My problem is I want to use my storefront to invoice and collect local service work. I am using a pay later invoice gateway that drops orders into processing & woo does not decrease stock in this status so the quantities I just sold are still listed as available in my product/catalog pages. However, I found that when a customer goes to add these intangible stock quantities they receive a message like unable to add to cart insufficient stock even though the catalog pages show its available.
I cannot figure out what function this would serve since the quantity is already spoken for in a payment pending order why is it showing in product/catalog pages. I showered every post I could find across 3 search engines trying to find a similar situation with an answer but haven't had much luck.
I found this:
function reduce_stock_processing($order_id) {
wc_reduce_stock_levels($order_id);
}
In a post with similar issues and tried to implement but it had no effect that I could see.
I then found this:
add_action( 'woocommerce_valid_order_statuses_for_payment', function( $statuses, $order ) {
$statuses[] = 'on-hold';
return $statuses;
}, 10, 2 );
But it allowed me to drop orders into an on-hold status where woo does pull stock and it allowed for payment to be made from that status. I thought this is great finally, but when I started another round of testing I found that if I created an order and purchased all the remaining stock of a certain product it would A: pull the stock from inventory correctly leaving product stock at zero, then B: when I sent an email invoice to customer with payable link.
It tells them that the order cannot be paid for since item is out of stock. Frustrating, because it handles orders with abundant stock well; after order completed I'm left with appropriate stock levels.
It seems that woo needs to have extra stock on hand to allow customers to pay.... or at least that is how it seems to me.
Any ideas on how I can achieve my goal? Thanks in advance.
Update-
So I changed the first code to this:
function reduce_stock_pending($order_id) {
wc_reduce_stock_levels($order_id);
}
add_action('woocommerce_order_status_pending', 'reduce_stock_pending');
and at first I thought it didn't work because the stock levels didn't change upon creating an order and having it drop straight to pending payment status, but after toggling the status to on-hold it reduced stock and when I toggle it back to pending status the stock remains reduced and with payment successful it does not further reduce stock so that seems at least workable considering I'm the moderator I'll know what to do.... but is there a better solution that would allow me to create an order and drop it straight into pending and have it reduce stock right away without having to toggle status back and forth.
-More Info
Order notes:
everything located above image only pertains to payment
So it seems to be rapidly increasing & then reducing stock on status change to pending. Again any help would be appreciated.

Php cart: how to store product information in cart

I want to make implement Cart funcionality in Laravel. I chose this plugin. But here and in many others cart packages I see that cart row stores not a product id but full information (product name, options, price). But what if the product title or product price was changed? Then the user still sees the old title (price) and it will cause some inconvienences to him. What I do not understand, why most cart packages store full information in cart row.
So what is the right way to store cart data: full info or by keys (product_id, option_id, ...)?
There is a preferred way to store cart information, and its the latter that you mentioned.
The reason for this is to not only increase the security of your shopping cart, but to also ensure that, as you rightly pointed out, customers are getting the right price, even after a change.
Typically what you want to do is store the product ID, any customisation options as well as a cart ID. Depending on the amount of products and the traffic you're receiving it may be unnecessary to work out the basket price each time a new page is loaded, and so typically you only work out a new price when a new product is added, taken away or modified; in addition to when the customer gets to the checkout area.
This serves several purposes,
the first is that is ensure that when the cart is directly changed by
a customer action, you can show an updated price.
The second is that you cut down the amount of calculations you have to do by a large amount by only changing the prices in the basket when something acts upon it.
You can ensure that customers cannot cheat the system by modifying the price, then going on to pay a different amount because you stored the price in the session.
I can't give you a more concrete answer because you've been fairly light on the specifics, but I hope this indicates the direction you should be heading in.

Magento Update Subtotal

I've tried the suggestions here: Magento update subtotal item
I have a Magento site with several extensions. We're using Amasty to add 'bonus' items. The problem is we want those items to show up and be added to the subtotal if the user selects 30 day billing.
I've tried making a simple extension and hooking to various events, but it looks like Amasty always has the last word when updating the subtotal.
I've even modified the Dispatcher so that it logs who it's dispatching to to see if I can track down where it's getting updated but to no avail.
How can I make sure that the extension I write is the final one to update the subtotal/total for the order?
It's right after checkout that it's being updated by something to exclude the bonus item.s
Checkout sort order for each order total module.
On times one of the order total modules sort order is higher then total module.
Or logically sort orders have some wrong values.
First you need to check that.
I had seen something similar happen when an old Magento commerce version was updated.

Opencart module quanity bespoke modification issue

I had a mod made for opencart enabling me to allow my local customers add additional item to their order 24 hours before local delivery.
Basically my shop is made up of one-off items and the quantity is generally 1
The modification that was made works fine but..
Say the conditions are: Iv'e added 3 items to my cart and processed my order for local delivery.
Then.. I go to add more to my order.
The form below on my pastebin allows me to add additional items to the order but when it does it re-checks the other items on the order and because they are technically out of stock they get removed from the amend order page.
I hope ive made sense and someone wants to help. Thanks!
CODE: http://pastebin.com/CsHts0FR

Adding cart error to prevent going into the checkout

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
I would suggest you to make a dedicated page let's call it edit_cart. When you are redirecting to checkout, check all products and validate their qty in magento. Push them to edit_cart and let them delete out of stock products from cart. After this redirect them to checkout.

Categories