Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add csv import feature #212

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading