Pregunta

Does anyone know the answer for the relationship between stock control and payment status?

Eg I want to create a new payment status called "On Hold" which decreases the stock of products in the order. or I want to create a new payment status called "Waiting for client" which doesn't decrease stock of products in the order.

When the OC decreases the stock of the product? When the OC reverses the stock of a product?

Or in other words: Is possible to create a hierarchy of payment status where the stock is only decreased from status X? (And vice versa in the case of reversal)

I'll explain : there are some status on the PayPal API that are not provided in OC. For example: Payment Review>Placed, Payment Review>Cleared, Temporary Hold>Placed etc.. In my case (paypal express default), the status of the payment for these status is "Awaiting Payment" (default) causing confusion in stock.

thanks all

¿Fue útil?

Solución

The idea is nice, but without logic. There is common sense in stock control and ordering: if client comes to your store, and the item has stock available, the client is able to order that stock and this stock should be blocked for him, either the payment process or clarification of details should take few weeks.

If it would happen, that I come to your store, I will see You are selling MacBook Air for $700 and You have two last pieces, I would order that two pieces and they should be blocked just for my order. But if You will wait for my payment (coz I paid by bank money transfer) and set a status "Waiting for client" while the stock is not blocked and somebody else comes after me and see these two Airs as available and do a quicker payment (e.g. via PayPal), it means that while my money is being transferred (that may last for 1-X days) You already sold the items I have ordered. This would mean that you, my dear, are a very unfair, untrustworthy and undisciplined seller.

So, how does the stock controll work in OpenCart is very common (and fair): if You have set in settings that stock is subtracted after order (this is done for each product, respectively, in it's details in administration, tab Data), after a confirmed order the stock is subtracted (blocked).

And the stock remains subtracted unless You cancel the order from whatever reason (I guess it is exactly Canceled order status - You may check the code to see).

And to Your PayPal Express Checkout - I do not know Your implementation, but I have implemented this few times and always set the order as paid unless an error or refusal comes from PayPal API. Anyway, You are able to create as many payment statuses as You wish and then edit the PP EC implementation to use these statuses, but unless the order is Canceled, the stock should be blocked for that client.

Otros consejos

Marco,

Without getting into the specifics of whether you should or shouldn't implement this on your site. My preferred technical way to implement this will be:

  1. Insert a new column to the product table. call it 'quantity_booked' or whatever descriptive name you choose.
  2. In your controller and model files, change everywhere you are calculating the stock to substract quantity_booked from quantity.
  3. Since you can't really trust a booked order 100%, try to figure out what's your 'booking/paying' ratio and take it in consideration when selling the products (just like all airlines do). So you can actually do the math as quantity = quantity - (0.7 * quantity_booked). 0.7 being an example for your effective confirmation ratio.
  4. when someone cancelles a booking/reservation, you can reduce it from the quantity_booked quantity.

Hope this helps!

I agree with you @shadyyx but I'd like to do some caveats.

My intention is not to decrease stock but to return the product to stock.

Imagine this:

1. User makes request - stock -1
2. Awaiting Payment - nothing to do

Two possible next steps:

3a. User has abandoned the purchase and after X days the administrator changes
the status to "Cancelled"
3b. The gateway refuses the payment and changes the status to "Denied" via IPN

In both cases, the product should automatically return to inventory (stock +1). This does not happen by default in OpenCart.

What I did?
At first returning to stock only when the status is changed to "Cancelled"

What I will do?
Assign +1 or -1 for each payment status and check the status for each order change.
Sample:
User makes an order - Awaiting for payment ( stock -1 )
Gateway is analyzing the payment - in Review ( do nothing because the stock has been reduced already )
Payment was confirmed - Payment Confimed ( do nothing because the stock has been reduced already )
Order was shipped - Shipped ( do nothing because the stock has been reduced already )
User refuses the delivery - Reversed ( I'm not sure if increase stock in this step )
User sends the products back - Awaiting Products ( is a return status - nothing to do )
User is refunded - Refunded ( stock +1 )

Why ?
I want to create the orders historic of the status of payment and today OpenCart only returns stock if order is deleted

That's it

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top