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

[CNT-30350]Split Order Fulfilment for AfterShip-WooCommerce plug-in #223

Merged
merged 26 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
39b2f20
[CNT-30350]Split Order Fulfilment for AfterShip-WooCommerce plug-in (…
kaolengmian7 Aug 1, 2024
db8b10b
[CNT30350]前端v2
kaolengmian7 Aug 1, 2024
2e25ce0
[CNT30350]前端v1
kaolengmian7 Aug 1, 2024
da1aa6b
[CNT30350]migrate old tracking data & 前端灰度
kaolengmian7 Aug 2, 2024
6a33e8b
[CNT30350]修改判断 null 的方式
kaolengmian7 Aug 2, 2024
8a2deb7
[CNT30350]兼容 old tracking
kaolengmian7 Aug 2, 2024
b6c9176
[CNT30350]兼容 old tracking
kaolengmian7 Aug 2, 2024
f14a9e9
[CNT30350]增加 try catch
kaolengmian7 Aug 2, 2024
9bb2a86
[CNT30350]用 let 替换 var
kaolengmian7 Aug 5, 2024
8033424
[CNT30350]用 let 替换 var
kaolengmian7 Aug 5, 2024
172c1dd
[CNT30350]使用工具函数
kaolengmian7 Aug 5, 2024
07495c3
[CNT30350]使用工具函数
kaolengmian7 Aug 5, 2024
c3b5437
[CNT30350]使用工具函数
kaolengmian7 Aug 6, 2024
c8814fc
[CNT30350]修改配置
kaolengmian7 Aug 7, 2024
2f80c9a
[CNT30350]修改配置
kaolengmian7 Aug 7, 2024
31748c0
[CNT30350]修改配置
kaolengmian7 Aug 7, 2024
deb22d2
[CNT30350]修改配置
kaolengmian7 Aug 7, 2024
e999a2d
[CNT30350]修改配置
kaolengmian7 Aug 7, 2024
1a26b40
[CNT30350]修改前端metabox title
kaolengmian7 Aug 8, 2024
3666daa
[CNT30350]修改前端metabox
kaolengmian7 Aug 8, 2024
0d7bb97
[CNT30350]修改前端metabox
kaolengmian7 Aug 8, 2024
7c3030a
[CNT30350]修改前端metabox
kaolengmian7 Aug 8, 2024
147e5ac
[CNT30350]修改前端metabox
kaolengmian7 Aug 8, 2024
a326073
[CNT30350]修改前端metabox
kaolengmian7 Aug 9, 2024
b847cff
[CNT30350]修改前端metabox
kaolengmian7 Aug 9, 2024
c068f5a
[CNT30350]重构后端文件结构
kaolengmian7 Aug 9, 2024
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
42 changes: 33 additions & 9 deletions aftership-woocommerce-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,29 @@ public function __construct() {
$this->includes();

// Check if woocommerce active.
// Add afterShip API to woocommerce REST API
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
add_filter( 'woocommerce_rest_api_get_rest_namespaces', array( $this, 'add_rest_api' ) );
}

// CSS
add_action( 'admin_print_styles', array( $this->actions, 'admin_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this->actions, 'load_orders_page_script' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'automizely_aftership_add_admin_css' ) );
// Remove other plugins notice message for setting and landing page
add_action( 'admin_enqueue_scripts', array( $this, 'as_admin_remove_notice_style' ) );

// Enqueue js on frontend.
add_action( 'wp_enqueue_scripts', array( $this, 'as_enqueue_frontend_js' ) );

add_action( 'add_meta_boxes', array( $this->actions, 'add_meta_box' ) );
// FE Order
add_action( 'admin_enqueue_scripts', array( $this->actions, 'load_orders_page_script' ) );
// FE Metabox
add_action( 'add_meta_boxes', array( $this->actions, 'add_meta_box' ) );
// CSS
add_action( 'admin_enqueue_scripts', array( $this, 'automizely_aftership_add_admin_css' ) );

// Remove other plugins notice message for setting and landing page
// Old Version Plugin
add_action( 'admin_enqueue_scripts', array( $this, 'as_admin_remove_notice_style' ) );
// Enqueue js on frontend.
// Old Version Plugin
add_action( 'wp_enqueue_scripts', array( $this, 'as_enqueue_frontend_js' ) );
// Old Version Plugin
add_action( 'woocommerce_process_shop_order_meta', array( $this->actions, 'save_meta_box' ), 0, 2 );

// register admin pages for the plugin
add_action( 'admin_menu', array( $this, 'automizely_aftership_admin_menu' ) );
add_action( 'admin_menu', array( $this, 'automizely_aftership_connect_page' ) );
Expand All @@ -168,29 +176,43 @@ public function __construct() {
* Admin Initialization calls registration
* We need this to send user to plugin's Admin page on activation
*/
// init configs & options
add_action( 'admin_init', array( $this, 'automizely_aftership_plugin_active' ) );
// UNKNOWN
add_action( 'admin_footer', array( $this, 'deactivate_modal' ) );

// View Order Page.
// Display tracking with templates
add_action( 'woocommerce_view_order', array( $this->actions, 'display_tracking_info' ) );
// Display email with templates
add_action( 'woocommerce_email_before_order_table', array( $this->actions, 'email_display' ), 0, 4 );

// Order page metabox actions.
// Old Version Plugin API
add_action( 'wp_ajax_aftership_get_item', array( $this->actions, 'get_meta_box_item_ajax' ) );
add_action( 'wp_ajax_aftership_delete_item', array( $this->actions, 'meta_box_delete_tracking' ) );
add_action( 'wp_ajax_aftership_save_form', array( $this->actions, 'save_meta_box_ajax' ) );
add_action( 'wp_ajax_aftership_get_items', array( $this->actions, 'get_meta_box_items_ajax' ) );

// API for FE
// Tracking API
add_action( 'wp_ajax_aftership_delete_order_tracking', array( $this->actions, 'delete_order_tracking' ) );
add_action( 'wp_ajax_aftership_save_order_tracking', array( $this->actions, 'save_order_tracking' ) );
add_action( 'wp_ajax_aftership_get_order_trackings', array( $this->actions, 'get_order_detail' ) );
add_action( 'wp_ajax_aftership_get_settings', array( $this->actions, 'get_settings' ) );
// Fulfillment API
add_action( 'wp_ajax_aftership_save_order_fulfillments', array( $this->actions, 'save_order_fulfillments_controller') );
add_action( 'wp_ajax_aftership_get_order_fulfillments', array( $this->actions, 'get_order_fulfillments_controller') );
add_action( 'wp_ajax_aftership_delete_order_fulfillments', array( $this->actions, 'delete_order_fulfillments_controller') );
add_action( 'wp_ajax_aftership_delete_order_fulfillment_tracking', array( $this->actions, 'delete_order_fulfillment_tracking_controller' ) );

// Register Add Tracking Action for AfterShip
// A button to update tracking status
add_filter( 'woocommerce_admin_order_actions', array( $this->actions, 'add_aftership_tracking_actions_button' ), 100, 2 );
// Custom AfterShip Tracking column in admin orders list.
add_filter( 'manage_shop_order_posts_columns', array( $this->actions, 'shop_order_columns' ), 99 );
add_action( 'manage_shop_order_posts_custom_column', array( $this->actions, 'render_shop_order_columns' ) );
// Custom AfterShip Tracking column in admin orders list(Woocommerce High-Performance Order Storage Support)
add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this->actions, 'shop_order_columns' ), 99 );
add_action( 'manage_woocommerce_page_wc-orders_custom_column', array( $this->actions, 'render_wc_orders_list_columns' ), 10, 2 );

Expand Down Expand Up @@ -226,9 +248,11 @@ public function __construct() {
add_filter( 'woocommerce_rest_shop_coupon_object_query', array( $this->actions, 'add_query' ), 10, 2 );
add_filter( 'woocommerce_rest_customer_query', array( $this->actions, 'add_customer_query' ), 10, 2 );

// install or uninstall
register_activation_hook( __FILE__, array( 'AfterShip', 'install' ) );
register_deactivation_hook( __FILE__, array( 'AfterShip', 'deactivation' ) );
register_uninstall_hook( __FILE__, array( 'AfterShip', 'deactivation' ) );
// string cache for AFTERSHIP_VERSION
set_transient( 'wc-aftership-plugin' . AFTERSHIP_VERSION, 'alive', 7 * 24 * 3600 );
}

Expand Down
4 changes: 4 additions & 0 deletions assets/frontendv2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!package.json
!yarn.lock
node_modules
# dist/
9 changes: 9 additions & 0 deletions assets/frontendv2/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100,
"semi": true,
"useTabs": false,
"tabWidth": 2,
"jsxBracketSameLine": true
}
33 changes: 33 additions & 0 deletions assets/frontendv2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Usage

Those templates dependencies are maintained via [pnpm](https://pnpm.io) via `pnpm up -Lri`.

This is the reason you see a `pnpm-lock.yaml`. That being said, any package manager will work. This file can be safely be removed once you clone a template.

```bash
$ npm install # or pnpm install or yarn install
```
### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)

## Available Scripts

In the project directory, you can run:

### `npm dev` or `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>

### `npm run build`

Builds the app for production to the `dist` folder.<br>
It correctly bundles Solid in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

## Deployment

You can deploy the `dist` folder to any static host provider (netlify, surge, now, etc.)
1 change: 1 addition & 0 deletions assets/frontendv2/dist/metabox/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/frontendv2/dist/metabox/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/frontendv2/dist/orders/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/frontendv2/dist/orders/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions assets/frontendv2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Solid App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<!-- <div id="root"></div> -->
<aftership-meta-box></aftership-meta-box>

<script src="/src/index.tsx" type="module"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions assets/frontendv2/inject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
console.log('inject.js');
const scriptElm = document.createElement('script');
scriptElm.src = 'http://localhost:3000/src/index.tsx';
scriptElm.type = 'module';

document.body.appendChild(scriptElm);
Loading