Created
July 22, 2024 06:40
-
-
Save adicahyaludin/e19eb581074cfe60ca228d57da4c90ec to your computer and use it in GitHub Desktop.
wc-order-payment-link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nwa_get_payment_link_by_order($order) | |
{ | |
$order_payment_link = $order->get_checkout_payment_url(); | |
do_action('inspect', ['0_order_payment_link', $order_payment_link, __FILE__, __LINE__]); | |
if (is_a($order, 'WC_Subscription')) : | |
$renewal_order_ids = $order->get_meta('_subscription_renewal_order_ids_cache'); | |
// do_action('inspect', ['1_renewal_order_ids', $renewal_order_ids, __FILE__, __LINE__]); | |
if (isset($renewal_order_ids[0]) && !empty($renewal_order_ids[0])) : | |
$renewal_order_id = $renewal_order_ids[0]; | |
$renewal_order = wc_get_order($renewal_order_id); | |
// do_action('inspect', ['1_renewal_order', $renewal_order, __FILE__, __LINE__]); | |
$order_payment_link = $renewal_order->get_checkout_payment_url(); | |
else : | |
$parent_order_id = $order->get_parent_id(); | |
$parent_order = wc_get_order($parent_order_id); | |
// do_action('inspect', ['1_parent_order', $parent_order, __FILE__, __LINE__]); | |
$order_payment_link = $parent_order->get_checkout_payment_url(); | |
endif; | |
endif; | |
do_action('inspect', ['1_order_payment_link', $order_payment_link, __FILE__, __LINE__]); | |
return $order_payment_link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment