In WooCommerce, the order pay page is a specific webpage a customer lands on to complete payment for an order. It’s typically used for manual orders.
When a store admin creates an order in the WooCommerce backend, the system generates a unique URL for the order pay page. This link can then be shared with the customer via email or other means, allowing them to submit payment.
The question is – what if we want the customer to pay a deposit / first installment / partial payment on the Order Pay page (say the order total is $999, and you want them to pay $111 only)?
Well, we could use a URL parameter – if that’s present and the value is lower than the order total, we can “filter” the order total and let the customer pay whatever amount. Let’s see how it’s done!
PHP Snippet: Force Deposit Payment @ WooCommerce Order Pay Page
Order Pay page URLs look like e.g. https://example.com/checkout/order-pay/123456/?pay_for_order=true&key=wc_order_Lertgern4556454DFG4a – as you can see, it already comes with URL parameters!
All we need to do now is add one more parameter – for example “dep” or whatever you wish – followed by an amount that must be less than the order total ($999 in our example): &dep=111
Final URL will be https://example.com/checkout/order-pay/123456/?pay_for_order=true&key=wc_order_Lertgern4556454DFG4a&dep=111
Now that we have “dep” and its “111” value in the URL, we can use the snippet below to alter the order total on the go:
/**
* @snippet Deposit Payment @ WooCommerce Order Pay
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_order_get_total', 'bbloomer_order_pay_deposit', 9999, 2 );
function bbloomer_order_pay_deposit( $total, $order ) {
if ( is_checkout_pay_page() && isset( $_GET['dep'] ) ) {
return (int) $_GET['dep'];
}
return $total;
}