Home > Blockchain >  how to change order status to complete and redirect to download page in Woocommerce
how to change order status to complete and redirect to download page in Woocommerce

Time:09-04

I have a Wordpress Woocommerce website that sells virtual downloadable products with some blockchain payment method in my custom payment gateway,

I need to handle a code while customer is in payment page in my website and call an Ajax to check if payment is completed and confirmed or not.

When Ajax get answer that shows payment confirmed (in blockchain) I need to update order status to completed and return thank you page with download link of my product.

$order = new WC_Order($order_id);
  
if (!empty($order)) {
     
     $order->update_status( 'completed' );

}

with this code I can update order status to 'completed' but I don't know how to return thank-you page with Download link for my Virtual Downloadable Product...

I can just redirect to

window.location.href = "'.get_home_url().'/checkout/order-received/";

but here there is not any download link.

CodePudding user response:

I tried:

 $this->get_return_url( $order )

and now i can redirect user to link mentiones above and user can get download link right after ajax answer with download link.

  • Related