Les meilleurs développeurs WooCommerce freelances sont sur Codeur.com

Process WooCommerce Pre-Order payment when order is marked as complete

 Fermé·Moins de 500 €·3 offres·681 vues


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.

Budget indicatif : Moins de 500 €

Publication : 01 septembre 2020 à 22h22

Profils recherchés : Expert Woocommerce freelance

Le profil du client est reservé aux prestataires abonnés

Créer un compte

3 freelances ont répondu à ce projet

3 propositions de devis en moins de 2h

Publier un projet similaire

Chaque jour, des centaines de clients utilisent Codeur.com pour trouver un prestataire. Créez votre compte dès maintenant, remplissez votre profil et trouvez de nouveaux clients.

Trouver des nouveaux clients

Votre navigateur Web n’est plus à jour. Il ne permet pas d’afficher correctement le site Codeur.com.
Nous vous invitons à mettre à jour votre navigateur ou à utiliser un autre navigateur plus récent.