Closed sanesh-acowebs closed 6 months ago
Hi @sanesh-acowebs,
Can you provide more details on what you're trying to do? The purchase event is triggered when the order is placed or checked out. Do you want to change when this happens?
Hi, We are using the deposit plugin for partial payment. So we have the option to pay the full amount or a partial amount. The issue that we are facing is that when a customer pays the full amount (as a normal order) its purchase events are correctly registered with Facebook. But when we try to make a partial payment, it is not registered. When we try to pay using partial payment, a new custom order status "partially paid" is used for tracking. So want to know whether there are any filters available to add custom order status in the purchase event.
Thanks for clarifying. I looked into this, and we only trigger the purchase event post-checkout with a fallback that runs on the thankyou_page. There are no filters to trigger this event at the moment.
Thanks for your reply. Can you give a little more clarity about the changes required. Currently, we are only changing the order status to "partially paid" other than normal "processing or completed".
We only trigger a purchase event once the checkout is completed. If you want a purchase to be sent when the status changes, this might require some custom logic. For example:
add_action('woocommerce_order_status_changed', 'send_purchase_event', 10, 3);
function send_purchase_event($order_id, $old_status, $new_status) {
$order = wc_get_order($order_id);
if ( ! $order ) {
return;
}
if ( 'your new status' === $new_status ) {
if ( function_exists( 'facebook_for_woocommerce' ) ) {
facebook_for_woocommerce()->get_integration()->events_tracker->inject_purchase_event($order_id);
}
}
}
However, I recommend against something like this as it uses the plugin's internal code, which may be subject to change. You can also add a feature request for this, and our team will review: https://woocommerce.com/feature-requests/facebook/
We have created a new feature request on the shared link. And also we will check the shared code and share our comments. Thanks.
Do you have any options for triggering a purchase event on a custom order status?