Yeah didn’t have an issue on mine.
View post on imgur.com
In my test my payment gateways didn’t show. obviously because it’s free.
Thread Starter
vato
(@vatanbytyqi)
Here is an image that shows my issue, payment isn’t possible from orders page
View post on imgur.com
Yeah sorry. It’s really hard to troubleshoot requests like these without a URL.
Thread Starter
vato
(@vatanbytyqi)
@serafinnyc you are involved in my other post as well. I have the link and credentials there to test, it’s the same site 😛
Thread Starter
vato
(@vatanbytyqi)
@serafinnyc could you verify the same behaviour on your site?
Thread Starter
vato
(@vatanbytyqi)
So the issue here is that the order needs to be completed from My Orders page, thus it’s not a bug in WooCommerce but a customization. Here is how to solve it.
The code that causes the problem is located here:
# includes/wc-class-order.php
/**
* Checks if an order needs payment, based on status and order total.
*
* @return bool
*/
public function needs_payment() {
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $this );
return apply_filters( 'woocommerce_order_needs_payment', ( $this->has_status( $valid_order_statuses ) && $this->get_total() > 0 ), $this, $valid_order_statuses );
}
More specifically this causes the problem $this->get_total() > 0
So to override this filter, add this to your functions.php
//Allow pay for order when the total price is $0.00 in frontend
function check_order_payment($th, $order, $valid_order_statuses) {
return $order->has_status( $valid_order_statuses );
}
remove_filter('woocommerce_order_needs_payment', WC_Order);
add_filter( 'woocommerce_order_needs_payment', 'check_order_payment', 10, 3 );
Hi @vatanbytyqi!
Nice solution!
I agree with you that this is not technically a bug, but expected behavior since the product is actually free and therefore wouldn’t need payment. But I also understand that you need this in your case 😉
I’m going to mark this as resolved now – if you have any further questions, you can start a new thread.