Hi @avinashdigitl
The hooks you’re currently using, woocommerce_checkout_order_processed
and woocommerce_thankyou
, should technically be triggered after an order is placed, regardless of the payment method used. However, it’s possible that Apple Pay, being a direct payment method, might be bypassing the standard WooCommerce checkout process.
To ensure that your custom code is triggered with Apple Pay, you could try using the woocommerce_payment_complete
hook. This hook is triggered when WooCommerce marks an order as ‘completed’, which happens after successful payment, regardless of the payment method.
Please note that you may have to adjust your function to work with this hook, as the woocommerce_payment_complete
hook passes the order ID as an argument, not the order object.
Additionally, you can also use the woocommerce_new_order
hook, which is triggered when a new order is created. You can use this hook to add custom code that sends an email to the customer or adds data as you mentioned. Here’s a basic example of how you might use this hook:
add_action( 'woocommerce_new_order', 'your_custom_function', 1, 1 );
function your_custom_function( $order_id ) {
// Your code here.
}
The woocommerce_new_order
hook should be triggered when the order is created, even if the customer doesn’t return to the thank you page. So you should be able to use this hook to accomplish what you’re trying to do.
Please note that this requires a good understanding of PHP and WordPress development. Unfortunately, custom coding is not something we can assist with directly. However, if you’re not comfortable with coding, you might want to hire a developer to help you with this.
If you have any further questions on development or custom coding, don’t hesitate to reach out to some of our great resources available for support. Our WooCommerce community is brimming with skilled open-source developers who are active on the following channels:
If you have any other questions or need further clarification, please don’t hesitate to ask.
Thanks!