add_action('rest_api_init', function() {
  register_rest_route('meowmesh/v1', '/steadfast-ids', [
    'methods'  => 'GET',
    'callback' => function(WP_REST_Request $req) {
      global $wpdb;
      $days = intval($req->get_param('days') ?: 30);
      $rows = $wpdb->get_results($wpdb->prepare(
        "SELECT pm.post_id as order_id,
                pm.meta_value as consignment_id,
                o.total_amount as cod_amount
         FROM wp_postmeta pm
         INNER JOIN wp_wc_orders o ON pm.post_id = o.id
         WHERE pm.meta_key = 'steadfast_consignment_id'
           AND pm.meta_value != ''
           AND o.date_created_gmt >= DATE_SUB(NOW(), INTERVAL %d DAY)",
        $days
      ), ARRAY_A);
      return $rows;
    },
    'permission_callback' => '__return_true',
  ]);
});<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://meowmesh.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://meowmesh.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-posts-cartflows_step-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-taxonomies-product_shipping_class-1.xml</loc></sitemap><sitemap><loc>https://meowmesh.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
