• Resolved tristanmason

    (@tristanmason)


    We are having a similar problem to the one described in the recent thread Don’t Export Fee Line Items to ShipStation. We are using the standard WooCommerce cart->add_fee() function to add an extra fee to certain orders, but Shipstation syncs the fee line item as if it were a product, even if all of the items in the order are virtual items.

    The expected behavior, like the other poster said, would be for Shipstation to ignore fees. I can provide more information if needed.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi there @tristanmason ??

    Thank you for contacting Woo support!

    Shipstation incorrectly syncing fees as products

    Could you provide further details on the WooCommerce cart->add_fee() function that is used to add an extra fee to certain orders, please?

    Furthermore, I’d like to understand more about your setup.

    Could you please send me a copy of your site’s System Status? You can find it via WooCommerce > Status. Select Get system report and then Copy for support.

    Once you’ve done that, you can paste it here or into our https://Quickforget.com service and send that secret link here.

    We await your response to better assist you.

    Thread Starter tristanmason

    (@tristanmason)

    @anastas10s Thanks for your reply!

    Here is the system report. Heads up, I’ve changed QuickForget expiration to 1 view/36 hours for this one. https://quickforget.com/s/dddd872a1b6c7ae3145527e18037e84ea7297e18b487f2a1

    And here is the code we are using to add the fee: https://quickforget.com/s/4cc8b37890ab278584f384ddae1c6bb7eb33db1ac9917b14
    It adds a checkbox in checkout so a customer can voluntarily donate the equivalent of the credit card processing fee, and then uses AJAX to add the fee using WooCommerce’s normal add_fee() method.

    Hi there @tristanmason

    It adds a checkbox in checkout so a customer can voluntarily donate the equivalent of the credit card processing fee, and then uses AJAX to add the fee using WooCommerce’s normal add_fee() method.

    Thank you for reaching back, elaborating further on this.

    Please note that we can’t provide support for code customization as per our support policy. Still, if you need customization, we do our best to offer advice and direct you to appropriate resources. Based on the feedback we get from our customers, we highly recommend contacting one of the services on our Customization page.

    I hope that helps!

    Thread Starter tristanmason

    (@tristanmason)

    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!

    Plugin Support Paulo P – a11n

    (@paulostp)

    Hello @tristanmason,

    Thanks for sharing the additional details. Let me check that with the developer team, I’ll write back soon.

    Best,

    Thread Starter tristanmason

    (@tristanmason)

    @paulostp Thanks for looking into this more! If we have to, we can change this fee to a hidden virtual product in order to bypass the issue. But I do think this is something that will probably keep coming up occasionally when people use the add_fee function, and it seems like a pretty simple adjustment to add a switch or filter for it.

    Plugin Support Paulo P – a11n

    (@paulostp)

    Hello @tristanmason,

    At a first glance the developer team agreed that this might be a bug, so I opened up a bug report for further investigation.

    At this point we don’t have an estimated time for the fix’s release, so I recommend checking the changelog when a new version gets released to confirm if this has been addressed.

    In the meantime, the solution presented on your other topic sounds like a good workaround.

    Thanks for bringing this to our attention.

    Thread Starter tristanmason

    (@tristanmason)

    @paulostp Great, thanks again for your help with this issue!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shipstation incorrectly syncing fees as products’ is closed to new replies.