| @@ -152,8 +152,20 @@ | ||
| 152 | 152 | array( 'status' => 404 ) |
| 153 | 153 | ); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | + /** | |
| 157 | + * Newest first. | |
| 158 | + * | |
| 159 | + * Campaign::get_campaigns() returns rows in insertion order, so the list showed the | |
| 160 | + * oldest campaign at the top. Sorted by id here rather than in the query | |
| 161 | + * or in Campaign::get_rows(): that order is also the order the intents | |
| 162 | + * are evaluated in, and it decides which campaign is credited when two | |
| 163 | + * produce the same discount, so reversing it there would quietly change | |
| 164 | + * attribution on the storefront. | |
| 165 | + */ | |
| 166 | + krsort( $campaigns, SORT_NUMERIC ); | |
| 167 | + | |
| 156 | 168 | foreach ( $campaigns as $campaign ) { |
| 157 | 169 | $response = $this->prepare_item_for_response( $campaign, $request ); |
| 158 | 170 | $data[] = $this->prepare_response_for_collection( $response ); |
| 159 | 171 | } |