Projets pour freelances & agences web

Retrouvez l'actualité des projets pour freelances et agences web.

Process woocommerce pre-order payment when order is marked as complete

Posté le 02/09/2020 à 04:30 - Budget : 0 - 500

I am trying to charge my clients in WooCommerce only when our Pre-Ordered activated items quit our warehouse.
To do so, I am using the Moneris payment gateway plugin with WooCommerce Pre-Order plugin that tokenize an securely store payment informations in a vault. I need to manually go into the plugin pre-order dashboard to complete the order which will then process the charge. We do that manually when items quit our warehouse.
To be proactive in our fulfillment process, we want to use an integration that simply connects between WooCommerce and our system and switch the order status to complete when it quit our warehouse.
The issue is that the WooCommerce Pre-Order plugin doesn't charge the client credit card if the order is switched to completed, it need to be processed in their Pre-Order dashboard first.
After taking a look at their documentation, it seems that pre-order payments are processed using this action below...
add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_payments' ) );
Now, Instead of modifying the plugin code directly, I am wondering if it would better to add a code snippet in my functions.php that would just call 'wc_pre_orders_process_pre_order_completion_payment_' everytime an order have a completed status in WooCommerce.
Maybe something like this could work:
/********************************************************************************
*** Woocommerce charge preorder when order status change to completed ***
*********************************************************************************/
function mysite_woocommerce_order_status_completed( $order_id ) {
// success!
if ( $transaction_successful ) {
// the total amount to charge is the the order's total
$total = $order->get_total();
// complete the order
$order->process_pre_order_payments();
}
else{
echo "not working";
}
}
add_action( 'woocommerce_order_status_completed', 'mysite_woocommerce_order_status_completed', 10, 1 );
I am looking for a dev that can help me achieve this.

Accéder à la fiche du projet

Autres projets susceptibles de vous intéresser