Hi @anastas10s,
Thanks, but I think we’re getting off track from my question. I don’t need support for code customization. I’m reporting what appears to be a bug in the plugin and asking for a way to fix it.
The problem is in the file /includes/api-export/class-wc-shipstation-api-export.php , starting at line 236:
// Item data.
$found_item = false;
$items_xml = $xml->createElement( 'Items' );
// Merge arrays without loosing indexes.
$order_items = $order->get_items() + $order->get_items( 'fee' );
foreach ( $order_items as $item_id => $item ) {
$product = is_callable( array( $item, 'get_product' ) ) ? $item->get_product() : false;
$item_needs_no_shipping = ! $product || ! $product->needs_shipping();
$item_not_a_fee = 'fee' !== $item->get_type();
if ( apply_filters( 'woocommerce_shipstation_no_shipping_item', $item_needs_no_shipping && $item_not_a_fee, $product, $item ) ) {
continue;
}
$found_item = true;
$item_xml = $xml->createElement( 'Item' );
$this->xml_append( $item_xml, 'LineItemID', $item_id );
if ( 'fee' === $item->get_type() ) {
$this->xml_append( $item_xml, 'Name', $item->get_name() );
$this->xml_append( $item_xml, 'Quantity', 1, false );
$item_total = $order->get_item_total( $item, false, true );
// Maybe convert fee item total.
if ( 1.00 !== $exchange_rate ) {
$item_total = wc_format_decimal( ( $item_total * $exchange_rate ), wc_get_price_decimals() );
}
$this->xml_append( $item_xml, 'UnitPrice', $item_total, false );
}
In line 240, it lumps all the products and fees together before exporting to the XML <Items>.
$order_items = $order->get_items() + $order->get_items( 'fee' );
Then on line 245, it skips the product if it’s virtual, but not if it’s a fee:
if ( apply_filters( 'woocommerce_shipstation_no_shipping_item', $item_needs_no_shipping && $item_not_a_fee, $product, $item ) ) {
continue;
}
The result is that even if all the products in the order are virtual, it still exports the order to Shipstation if there is a fee in the order. It should not do this since not all fees are shipping fees.
Especially since I’m not the only one who has asked about this recently (see other support post I linked to)—is there a way for us to bypass this behavior? For example, a filter hook, a constant, or a setting that would instruct the plugin not to export fees if all the items are virtual.
Thanks!