Fix for issue with wrong price, tax and discount when quantity greater than 1 and tax is applied after discount.
Merge pull request #2447 from AlexMyr/master

#2446 Fix for issue with wrong price, tax and discount when quantity > 1 and tax is applied after discount.
Bug in EDD reports if columns are deleted

I'm using the edd_export_csv_cols_payments filter to remove (and add - but I don't think that's important) some columns from a report with "unset( $columns['address1'] )" etc.

The bug showed itself in the omission of a comma between two fields in the CSV file (in my case I was looking at the products report, but I think it probably affects other reports too). As a result, when you import the CSV file into a spreadsheet, you get two fields joined in the same cell. Delete one field & it's the last comma missing in each row (between fields n & 'n-1'). Each additional field you delete moves the missing comma one field to the left.

Looking at the code here, if you delete any columns from the report then the number of 'columns' in the data array ($data) is greater than the number in the column headers array ($cols).

The loop on line 147 goes through each element in the data, then line 149 discards any items which aren't in the required output columns.

The code manages a counter $i which tracks when you get to the final column (judged by the number of column headers) and decides whether or not to add a comma after the value.

The OLD code incremented the counter regardless of whether the data value was output into the report. This has to be wrong - you only want to advance the counter if you've actually outputted the value as discarded fields don't affect the layout.

Also the "+1" in the comparison is at odds with the code on line 100 - I don't think the offset is needed.
Merge pull request #2527 from jonjennings/patch-1

Bug in EDD reports if columns are deleted
xhrFields for withCredentials: true to ajax requests. #2097
Use correct capability to check ability to export records

See issue #2534

Users with export_shop_reports capability should be able to export the shop reports. By validating against manage_options the code was denying users with the role shop_manager or shop_accountant (who have export_shop_reports capability but don't have manage_options) and limiting export to administrators only.
Merge pull request #2535 from jonjennings/patch-2

Use correct capability to check ability to export records
Pass final cart taxes to edd_sanitize_amount()
Check if post exists before deleting

If you do a bulk delete and then go to the previous page using pagination you get a ton load of notices -

`Notice: Trying to get property of non-object in /wp-content/plugins/easy-digital-downloads/includes/payments/functions.php on line 254`

We should check if the post exists before attempting to delete it.
Merge pull request #2543 from elliott-stocks/patch-6

Check if post exists before deleting