Skip to content

Instantly share code, notes, and snippets.

@santanup789
Created August 23, 2021 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santanup789/998c7aed7ecdf6cfcb3805a30ea2318c to your computer and use it in GitHub Desktop.
Save santanup789/998c7aed7ecdf6cfcb3805a30ea2318c to your computer and use it in GitHub Desktop.
Add custom link on WooCoommerce Received page for a particular product purchase and if the order status is processing or completed.
//Providing the Gold pack download link on the order receive page.
add_filter('woocommerce_thankyou_order_received_text', 'woo_change_order_received_text', 10, 2 );
function woo_change_order_received_text( $str, $order_id ) {
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item_id => $item ) {
$product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id();
if ( $product_id === 8936 ) {
if( $order->get_status() == 'processing' || $order->get_status() == 'completed' ) {
echo '<h3 style="background: #70C0AD;font-size: 24px;padding: 20px;margin-bottom: 30px; color: #fff;">You have successfully purchased <a href="#" target="_bkank" style="Color: #000; font-weight: bold;">Kidney Solution Gold Pack</a>. Please download the package from <a href="#" target="_bkank" style="Color: #000; font-weight: bold;">HERE</a>.</h3>';
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment