Add_action hook when Refund is done VIA Woocommerce API - wordpress

My order data is automatically synced between woocomerce and google firebase. E.g. when a order is placed in woocomerce, the data is sent directly to firebase.
But when I use woocommerce Refund API Endpoint to make partial refunds to my orders, the refund data is not syned to firebase.
A workaround is to open the order from woocommerce backend in my browser, and simply click update post. This seems to trigger the order to resync with firebase including the refund data.
Therefore I am trying to use the below code to Update post when a refund is created via API. But I am not sure if it is entirely correct. Please help.
// Update Order Page Once More afetr Refund is Done to Trigger FIREBASE Update
add_action( 'woocommerce_refund_created', 'zed_refresh_order_page' );
function zed_refresh_order_page($post_id) {
wp_update_post( $post_id);
}

Related

WordPress : trigger action when CPT created from API, or when updated from UI

I am searching all places for a way to update a post once it has been created or updated and saved (including meta data). In my case, new posts are and will always be created from the WP REST API only, and can be updated from the WP REST API and/or the WP UI.
I got the the post update portion of code, relying solely on a post meta field, up and running, working on itself. But I can’t find what hook to use to achieve the post update:
save_{cpt_name} -> post_meta is null, whatever the priority,
rest_insert_{cpt_name} -> not called on post update,
wp_after_insert_post -> not called on post update,
If you ave a reliable hook for me to play with, or a solution where I can grab a post meta key on post create, and post update, whatever the source (API or UI), could you share it with me ?
Thanks.

Woocommerce: getting customer e-mail when hooking into 'applied coupon' action

I found there is an action called woocommerce_applied_coupon that passes the coupon code down to the hook you write.
But, my use-case is this: I want to update a tag on the mailchimp-subscriber information on certain coupons being used. That way, we prevent sending e-mails reminding customers about the coupon if they already used it.
Is there a way to get the customer information when hooking into the woocommerce_applied_coupon action so I know which contact to update?

Subscribe to watch the video wordpress

I have added a video on my WordPress website and I want user first subscribe only then they should be able to play the video. I tried some Subscription plugin but not able to do it. Is there any way to do it in WordPress.
You need to use the following plugin in order to achieve the same functionality.
WooCommerce Subscriptions
Groups
Groups for WooCommerce
After the installation , you need to create a group and assign a page marked to that group so that only authorized customers from that group only can see the video page.
Assign the group to the subscription so that User will automatically added to the group after purchase of subscription.
You can also achieve the same functionality with gravity form subscriptions plugin.

Save custom post fields value before Woocommerce email send

I have an issue regarding emails sent by Woocommerce.
I have multiple custom fields, set up using the ACF plugin, for Wooocomerce orders. These fields contain additional info that should be visible in the emails sent to the user.
But for some reason I can't get them to save before the email is send and thus the email is empty of those values. Only after I click resend email are the values visible.
I tried prioritizing the action hooks using the Prioritize Hooks plugin but to no avail. Tried multiple things in order to prioritize.
I have the Woocommerce emails set up in the template that I use and get retrieve the custom fields like this:
$fields = get_field('fields', $customer_order->ID);
How can I get this to work properly? Any help is appreciated.
you need to store your data before send the email, so you need to find the correct hook.
If i'm not wrong the before_woocommerce_pay hook is your answer check here for more woocommerce hooks

i want to display the order details after the customer has completed payment through pay pal

I am using PayPal for the shopping cart
The code works fine. after payment when it comes to return URL, i want to display an order summary to customer.
can someone guide me on fetching the order_amt, transactionid, and displaying the same on the page?
Use PayPal's PDT and IPN services.
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables

Resources