Skip to content

Commit

Permalink
Merge pull request #226 from kaolengmian7/fix/30350
Browse files Browse the repository at this point in the history
[CNT30350]multiple tracking number in one shipment
  • Loading branch information
hefawei authored Aug 15, 2024
2 parents a96ab3a + 982ac5f commit 5a43ce4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion aftership-woocommerce-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ private function includes() {
// require new files, don't adjust file order
require_once( $this->plugin_dir . '/includes/define.php' );
require_once( $this->plugin_dir . '/includes/class-aftership-import-csv.php' );
$this->import_csv = new AfterShip_Import_Csv($this->actions, $this->couriers);
$this->import_csv = new AfterShip_Import_Csv($this->couriers);
require( $this->plugin_dir . '/includes/class-aftership-fulfillment.php' );
$this->fulfillment_actions = AfterShip_Fulfillment::get_instance();
}
Expand Down
2 changes: 1 addition & 1 deletion assets/frontendv2/dist/orders/index.js

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions includes/class-aftership-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,13 @@ public function convert_old_meta_in_order( $order_id ) {
return;
}

$tracking_items = $this->get_tracking_items($order_id);
foreach ($tracking_items as $item) {
if ($item['tracking_number'] === $tracking_number && $item['slug'] === $aftership_tracking_provider_name) {
return;
}
}

// 需要判断 _aftership_tracking_provider_name 是否正确,否则 slug 为 空
$slug = null;
// 值是正确的slug,直接使用
Expand Down Expand Up @@ -1106,12 +1113,17 @@ public function render_wc_orders_list_columns( $column_name, $order ) {
public function get_automizely_aftership_tracking_column( $order_id ) {
ob_start();

$fulfilments = AfterShip_Fulfillment::get_instance()->get_fulfillments_by_wc( $order_id );
$tracking_items = [];
foreach ($fulfilments as $fulfilment) {
if (isset($fulfilment['trackings'])) {
$tracking_items = array_merge($tracking_items, $fulfilment['trackings']);
$version = AfterShip_Fulfillment::get_instance()->frontend_version_controller();
if ( $version === 'v2' ) {
$fulfilments = AfterShip_Fulfillment::get_instance()->get_fulfillments_by_wc( $order_id );
foreach ($fulfilments as $fulfilment) {
if (isset($fulfilment['trackings'])) {
$tracking_items = array_merge($tracking_items, $fulfilment['trackings']);
}
}
} else {
$tracking_items = $this->get_tracking_items( $order_id );
}

if ( count( $tracking_items ) > 0 ) {
Expand Down
9 changes: 6 additions & 3 deletions includes/class-aftership-import-csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
exit;
}

//require 'import/data.php';
//require 'import/log.php';
//require 'import/functions.php';

class AfterShip_Import_Csv {
protected $settings;
protected $options;
Expand All @@ -24,8 +28,7 @@ class AfterShip_Import_Csv {
protected $selected_carrier_slugs;
protected $actions;

public function __construct( $actions, $couriers ) {
$this->actions = $actions;
public function __construct( $couriers ) {
$this->options = get_option( 'aftership_option_name' ) ? get_option( 'aftership_option_name' ) : array();
$selected_carrier_slugs = explode( ',', ( isset( $this->options['couriers'] ) ? $this->options['couriers'] : '' ) );
$this->selected_carrier_slugs = array_filter( $selected_carrier_slugs );
Expand Down Expand Up @@ -497,7 +500,7 @@ public function import_tracking( $order_id, $data, $import_options, $order_numbe
'tracking_number' => $item['tracking_number'],
'line_items' => $import_line_items,
);
$updated_order_tracking = $this->actions->post_order_tracking( $order_id, $post_tracking_params );
$updated_order_tracking = AfterShip_Actions::get_instance()->post_order_tracking( $order_id, $post_tracking_params );
if ( count( $updated_order_tracking ) ) {
$change ++;
} else {
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ Tailor a dynamic branded tracking page. Upload promotional banner, logo, and fav
== Changelog ==

= 1.17.15 =
* Support Multi Tracking Numbers in one Shipments (BETA)
* Support multiple tracking numbers in one Shipment (Beta)
* Enable the option to select 'Other' as a courier when fulfilling orders.

= 1.17.14 =
* Fix known issue
Expand Down

0 comments on commit 5a43ce4

Please sign in to comment.