i am completely customizing the woocommerce downloads page, i created a column named subscription in the downloads table and i want to get the id of the subscriptions, i'm a complete beginner and i'm learning, so please don't react negatively to what you think is my simple question, this is the code i wrote, but it doesn't display anything :
path : /themes/theme-name-child/woocommerce/order/order-downloads.php
<?php
$order = wc_get_order( $order_id );
$subscriptions = wcs_get_subscriptions_for_order( $order, array( 'order_type' => 'any' ) );
foreach ( $subscriptions as $subscription_id => $subscription ) {
?>
<a href="<?php echo esc_url( $subscription->get_view_order_url() ); ?>"><?php echo esc_html( $subscription->get_order_number() ); ?></a>
<?php } ?>
where is the mistake? please guide me
CodePudding user response:
<?php
$args = array(
'subscriptions_per_page' => 6,
'paged' => 1,
'offset' => 0,
'orderby' => 'start_date',
'order' => 'DESC',
'customer_id' => 0,
'product_id' => 0,
'variation_id' => 0,
'order_id' => 0,
'subscription_status' => array( 'any' ),
'meta_query_relation' => 'AND',
);
$subscriptions = wcs_get_subscriptions( $args );
foreach ( $subscriptions as $subscription ) {
?>
<a href="<?php echo esc_url( $subscription->get_view_order_url() ); ?>"><?php echo esc_html( $subscription->get_order_number() ); ?></a>
<?php } ?>
i hope it helps