public function send_split_orders($rows, $orders) { global $wpdb; $new_rows = array(); foreach ($rows as $i => $row) { $ids = WC_MS_Order_Shipment::get_by_order($row['ID']); if (count($ids) > 0) { foreach ($ids as $id) { $shipment = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE ID = %d", $id), ARRAY_A); $new_rows[] = $shipment; } unset($rows[$i]); } } $rows = array_merge($rows, $new_rows); return $rows; }
<?php $shipments = WC_MS_Order_Shipment::get_by_order($post->ID); foreach ($shipments as $shipment_id) { $shipment = WC_MS_Compatibility::wc_get_order($shipment_id); ?> <div class="wc-shipment" id="wc-shipment-<?php echo $shipment_id; ?> "> <div class="address"> <strong><?php _e('<strong>Ship To:</strong><br/>', 'wc_shipping_multiple_address'); ?> </strong> <?php echo $shipment->get_formatted_shipping_address(); ?> <br/> (<a href="#" class="edit-shipment-address">Edit</a>) </div> <div class="edit_shipping_address" style="display:none;"> <?php $shipFields = WC()->countries->get_address_fields($shipment->shipping_country, 'shipping_'); if ($shipFields) { foreach ($shipFields as $key => $field) { if (!isset($field['type'])) { $field['type'] = 'text'; }
function order_meta_box($type) { global $post; $addresses = get_post_meta($post->ID, '_shipping_addresses', true); $methods = get_post_meta($post->ID, '_shipping_methods', true); $multiship = get_post_meta($post->ID, '_multiple_shipping', true); $shipments = WC_MS_Order_Shipment::get_by_order($post->ID); if ($multiship == 'yes') { add_meta_box('wc_multiple_shipping', __('Order Shipping Addresses', 'wc_shipping_multiple_address'), array($this, 'packages_meta_box'), 'shop_order', 'normal', 'core'); /*if ( count( $shipments ) == 0 ) { add_meta_box( 'wc_multiple_shipping', __( 'Order Shipping Addresses', 'wc_shipping_multiple_address' ), array( $this, 'packages_meta_box' ), 'shop_order' , 'normal', 'core' ); } else { add_meta_box( 'wc_order_shipments', __( 'Order Shipments', 'wc_shipping_multiple_address' ), array( $this, 'shipments_meta_box' ), 'shop_order' , 'normal', 'core' ); }*/ } }