Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Matt

WooCommerce Tax column is not exporting when hpos is used

When setting up a custom order view using Admin Columns Pro with the WooCommerce Add-on the tax field appears to allow the export option but it doesn’t actually export.

This seems to be related to using WooCommerce hpos. It also doesn’t seem to work when you have hpos enabled and the “Enable compatibility mode (synchronizes orders to the posts table).” option enabled.

It seems that the old method had public/wp-content/plugins/admin-columns-pro/addons/woocommerce/classes/Column/ShopOrder/Tax.php included the use ACP\Export;, it also has an export class.

Wherthe public/wp-content/plugins/admin-columns-pro/addons/woocommerce/classes/Column/Order/Tax.php is missing this.

It seems like it is missing some items the old method had public/wp-content/plugins/admin-columns-pro/addons/woocommerce/classes/Column/ShopOrder/Tax.php

When I update public/wp-content/plugins/admin-columns-pro/addons/woocommerce/classes/Column/ShopOrder/Tax.php to include the following and the export function it worked again.


namespace ACA\WC\Column\Order;

use AC;
use ACA\WC\Sorting\Order\OrderData;
use ACP\ConditionalFormat\FilteredHtmlFormatTrait;
use ACP\ConditionalFormat\Formattable;
use ACP\Sorting\Sortable;
use ACP\Sorting\Type\DataType;
use ACP\Export;

class Tax extends AC\Column implements Export\Exportable, Formattable, Sortable

I’m hoping this could get added to the next release.

Please let me know if you need any additional information.

1 month ago
Matt

Wrote a quick patch to resolve my issue without altering the plugin directly.

/**
 * Add order tax to export.
 *
 * @param string $value       Column value to export for item.
 * @param Column $column      Column object to export for.
 * @param int    $id          Item ID to export for.
 *
 * @return string
 */
function acp_add_order_tax_to_export( $value, $column, $id ) {

	// If the value is not an empty and it is not the order tax column return.
	if ( ! empty( $value ) && 'column-order_tax' !== $column->get_type() ) {
		return $value;
	}

	// Get the order tax.
	$taxes = wc_get_order( $id )->get_tax_totals();

	// if there are no taxes return the value.
	if ( empty( $taxes ) ) {
		return $value;
	}

	$result = array();
	foreach ( $taxes as $tax ) {
		$result[] = sprintf( '%s: %s', $tax->label, $tax->formatted_amount );
	}

	$value = implode( '|', $result );
	return $value;
}
add_filter( 'ac/export/value', '\acp_add_order_tax_to_export', 10, 3 );
1 month ago
Stefan van den Dungen Gronovius
Developer

We implemented the export model for the Tax column again for the next update.

1 month ago

You must be logged in to reply to this topic.