• Resolved dwdonline

    (@dwdonline)


    I am trying to add product options for WooCommerce to be sent to Shipstation. I am able to accomplish this when editing class-wc-shipstation-api-export.php by inserting the following code just after line 273 – just before the first instance of $items_xml->appendChild( $item_xml ); .

                        $sashPreview = $item['vpc-custom-data']['preview_saved'];
                        //Get the flag sides for dual-country sash
                        $sashSideOne = $item['vpc-cart-data']['Why'];
    
                        if ( !empty( $sashPreview ) ) {
                            if ( !empty( $sashSideOne ) ) {
                                $options_xml = $xml->createElement( 'Options' );
                                    $option_xml  = $xml->createElement( 'Option' );
                                        $this->xml_append( $option_xml, 'Name', 'Why' );
                                        $this->xml_append( $option_xml, 'Value', wp_strip_all_tags( $sashSideOne) );
                                    $options_xml->appendChild( $option_xml );
                                $item_xml->appendChild( $options_xml );
                            }
                        }

    However, the problem is that when the plugin is updated, it overwrites my code. Is there another way to do this – maybe a hook, other than the custom field. The custom field hook does not work because this isn’t a custom field. It’s being mapped to the Product Options in ShipStation. The plugin already maps some product options, but in this case, it doesn’t because of it being a third-party plugin that creates these options in WooCommerce.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Michael K

    (@mikkamp)

    Automattic Happiness Engineer

    Hi,

    There isn’t a hook available for adding additional XML data to the export. However you can use the custom fields to add additional information. If you want to return something different then the meta data you will need to use two filters to enable the field and return a custom value. You can do that with a code snippet something like this:

    
    add_filter( 'woocommerce_shipstation_export_custom_field_2', '__return_true' );
    
    add_filter( 'woocommerce_shipstation_export_custom_field_2_value', 'woo_shipstation_custom_field_2_value', 10, 2 );
    function woo_shipstation_custom_field_2_value( $value, $order_id ) {
    	$order = wc_get_order( $order_id );
    	if ( $order ) {
    		// Return some data here for the custom field
    		return $order->get_order_number();
    	}
    	return $value;
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘Using Shipstation Order Information Fields’ is closed to new replies.