Skip to content

Commit

Permalink
Merge pull request #212 from yangyao/traffic
Browse files Browse the repository at this point in the history
Add csv import feature
  • Loading branch information
yangyao authored Oct 8, 2023
2 parents f7307db + 67d6be3 commit 465a57b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions includes/class-aftership-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ public function show_notices() {
'plugin-install',
'shop_order',
'edit-shop_order',
'woocommerce_page_wc-orders',
);
if ( ! in_array( $screen, $pages_with_tip ) ) {
return;
Expand Down
25 changes: 21 additions & 4 deletions includes/class-aftership-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public function page_init() {
'aftership_setting_section_id'
);

add_settings_field(
'enable_import_tracking',
'',
array( $this, 'enable_import_tracking_callback' ),
'aftership-setting-admin',
'aftership_setting_section_id'
);

add_settings_field(
$this->dom_id_show_order_actions,
'',
Expand Down Expand Up @@ -164,7 +172,9 @@ public function sanitize( $input ) {
}

if ( isset( $input['enable_import_tracking'] ) ) {
$new_input['enable_import_tracking'] = intval( $input['enable_import_tracking'] );
if ($input['enable_import_tracking'] == 'on' || $input['enable_import_tracking'] === true || intval($input['enable_import_tracking']) === 1 ) {
$new_input['enable_import_tracking'] = 1;
}
}

if ( isset( $input['show_orders_actions'] ) ) {
Expand Down Expand Up @@ -212,9 +222,6 @@ public function couriers_callback() {
if ( isset( $this->options['connected'] ) ) {
echo '<input type="hidden" id="' . $this->dom_aftership_connected . '" name="aftership_option_name[connected]" value="' . $this->options['connected'] . '" />';
}
if ( isset( $this->options['enable_import_tracking'] ) ) {
echo '<input type="hidden" id="' . $this->dom_aftership_enable_import_tracking . '" name="aftership_option_name[enable_import_tracking]" value="' . $this->options['enable_import_tracking'] . '" />';
}
}

/**
Expand All @@ -227,6 +234,16 @@ public function custom_domain_callback() {
);
}

/**
* Call this func before shown on pages.
*/
public function enable_import_tracking_callback() {
printf(
'<div class="auto-as-admin-checkbox-title">Enable CSV Tracking Import</div><label><input type="checkbox" id="enable_import_tracking" name="aftership_option_name[enable_import_tracking]" %s>Enable</label>',
( isset( $this->options['enable_import_tracking'] ) && 1 === $this->options['enable_import_tracking'] ) ? 'checked="checked"' : ''
);
}

/**
* Call this func before shown on pages.
*/
Expand Down

0 comments on commit 465a57b

Please sign in to comment.