Ecommerce Shopify WordPress Discussion

Add a Track shipping button to WooCommerce My acccount Orders

I am trying to add Track shipping button to WooCommerce My account orders that tracks order from the order ID, using the following code in funtions.php file of my child theme. add_filter( 'woocommerce_my_account_my_orders_actions', 'my_code_add_myaccount_order_track_button', 10, 2 ); function my_code_add_myaccount_order_track_button( $actions, $order ) { // Retrieve tracking link based on order ID (replace this with your logic to get the tracking link) $order_id = $order->get_id(); $tracking_link = get_post_meta( $order_id, '_tracking_link', true ); // Assuming you store the tracking link in a custom field if ( ! empty( $tracking_link ) ) { $actions['track'] = array( 'url' => $tracking_link, 'name' => __( 'Track', 'woocommerce' ), ); } return $actions; } But it doesn't work at all. What I am doing wrong?
As WooCommerce is migrating progressively to custom database tables, you should use CRUD methods, but not anymore WordPress post meta functions, especially if High-Performance Order Storage is enabled. Assuming that customer orders have a tracking URL registered as custom order metadata, try the following code replacement: add_filter( 'woocommerce_my_account_my_orders_actions', 'my_account_my_orders_tracking_button', 10, 2 ); function my_account_my_orders_tracking_button( $actions, $order ) { // Get tracking link custom metadata $tracking_link = $order->get_meta('_tracking_link'); if ( ! empty( $tracking_link ) ) { $actions['track'] = array( 'url' => $tracking_link, 'name' => __( 'Track', 'woocommerce' ), ); } return $actions; } Code goes in functions.php file of your child theme (or in a plugin). Tested and works.

January 10, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.