Get all woocommerce payment status is processing - wordpress

I m looking for a way to count all woocommerce orders that the status is "processing".
I looked for woocommerce_payment_complete/status hooks but cant figure out how to make a counter.
I need to add to my Woocomerce emails a new number/orderNumber that is not the normal woo order number but the new number that is the count of the complete payment
(example:
order:1, payment number :1
order:2, no payment
order:3, payment number:2
...
)
can anyone point me in a direction where I can start?

Related

Woocommerce - let customer pay for order when order column value is late payment

I have a difficult problem which i'm trying to solve for some time now.. We are using plugin called admin customer order fields, which let's to create a new column for order. For this part I have made second order status which is called "Payment status" - it can be not paid, paid, or late payment. And these statuses work depending on payment type. For example if customer pays via bank, status becomes "pending" and second column becomes "not paid". But the problem is that we are using Partial Payments plugin, which let's customer to pay for order after some time, for example 30 days. But during these 30 days the product will be shipped to his address and he can pay for order later. The logic is like this:
Customer orders product with option to pay after 30 days.
Order status becomes processing / payment status becomes not paid
And administrator can change the order status - if he ships it it becomes completed. So the statuses would be:
Order status - completed / payment status - not paid. And it should still let user to pay for the order even if order status is completed
Is it possible to make, that it customer could pay for order depending on payment status, not default order statuses? As the best what I have found is this hook:
woocommerce_valid_order_statuses_for_payment
But you can only make that the order statuses could be valid for payments, but I need to make it on payment status which is made with custom plugin.
Attaching screenshot to be clear as possible.
The idea is to make that if payment status is "APMOKĖTA" you couldn't pay anymore, and if it's "ATIDĖTAS MOKĖJIMAS" you could pay for your order.
You can try using the woocommerce_order_needs_payment hook like this
add_filter( 'woocommerce_order_needs_payment', 'custom_needs_payment', 10, 2 );
function custom_needs_payment( $needs_payment, $order ){
$payment_status = get_post_meta( $order->get_id(), 'payment_status', true );
if($payment_status == 'APMOKĖTA'){
return false;
}
return true;
}
You might need to change the names of the post meta to whatever it's named on your end

Change order creation after a successful payment in WooCommerce

Actually with WooCommerce, an order is create before the payement arrive (pending).
I need to remove this statut and create and order only when the payement is success for have something like this :
Customer order > Processing > Complete or Refund.
Thanks for the help.

Big Commerce Cart Subtotal global variable name

I've asked Big Commerce on their community forum and in the help (chat) - I'm after the GLOBAL variable name for the cart subtotal.
I need to include this in my invoice / tax receipt email.
Currently I just add this to the bottom of my standard Invoice.
RECEIPT FOR DONATION
Received from: %%GLOBAL_ShipFullName%%
Amount: %%GLOBAL_SideCartTotalCost%%
Date: %%GLOBAL_DatePlaced%%
__
NB: the SideCartTotalCost doesn't survive as a variable through to the Invoice stage, so nothing is displayed in the email sent to purchasers.
Any thoughts or suggestion most welcome. I have a case open with Big Commerce but so far nothing has come from that.

WooCommerce Order Status & reduce Stock

i write a payment gateway for woocommerce and i change the order status after payment is success. If status change to processing i reduce the order stock. Everything goes well.
By the way in the plugin settings the admin can change the status for success payments... processing or completed (for physical or virtual products)
function setOrderPaid($OrderID, $status){
$order = new WC_Order($OrderID);
if(!$order){
return false;
}else{
$order->update_status($status);
if($status=="processing") $order->reduce_order_stock();
WC()->cart->empty_cart();
return true;
}
}
After a success payment with changing the order status to processing, i go and change the status manual to completed (backoffice woocommerce->orders) and the system reduce the order stock again.
I have to reduce the stock after the success payment, to prevent problems with other orders on the same product. How can i fix this order reduce problem?
I find this Woocommerce set_status. Maybe this helps... bool $manual_update is this a manual order status change? So the system knows that stock is already reduced???
This has to do with what are considered as paid order statuses in woocommerce. You can customize the list of paid order statuses. The above function will trigger each time the order enters any of those paid order statuses.
Now, your first instinct would be to truncate the paid status list. This may be advisable in a few cases, but in this particular case the instinct is wrong.
What you need to do instead is check the current order status. If the status is not a paid status, only then you should trigger the reduce stock function. This assumes that the order won't jump between a paid and unpaid status repeatedly.

WooCommerce: Out of stock notification issue for a product with low stock

I have set stock for a product to 1. But when I test this setting on front office, trying to buy it, I have this error message:
'Sorry, we do not have enough "product name" in stock to fulfill your order right now. Please try again in 60 minutes or edit your cart and try again. We apologise for any inconvenience caused.'
I don't understand why I have this error, because there is 1 item in stock for this product.
How to get rid of this issue?
For Stock / Inventory product purposes in WooCommerce:
1) Woocommerce settings > Products (tab) > Inventory (sub-tab):
Normally your stock management is enable.
You need to set the Out Of Stock Threshold to 0
You can disable Low Stock Thresold notifications too, if needed.
2) At individual product level (on product pages) > Product data meta box > inventory (tab):
You can "Enable stock management at product level" and have individual settings for a specific product. So you will have to check there too.
I had the same issue and after some digging found that one paypal payment for the product in question is 'pending' that means the person did not have sufficient funds in her paypal account and paypal is waiting to get verification from the bank. The seat will not be released for purchase or show out of stock until paypal secures the funds. Hope this helps.
This is not a perfect solution, but see:
WooCommerce > Settings > Products > Inventory
And clear this settings like this:
Like i said, this is not a perfect solution, since it disables one of the many functions of this plugin, but it helps till the wooteam fix this problem.
The solution is to leave blank "Hold Stock (minutes)"

Resources