Skip to content

Commit

Permalink
Woocommerce 本次升級與優化
Browse files Browse the repository at this point in the history
- 相容版本:PHP8.1 / Woocommerce8.1.1 / Wordpress 6.3.1
- 新增TWQR及BNPL付款方式
- 優化金物流、發票模組各項設定
- 語系檔調整
  • Loading branch information
AllennChang committed Mar 7, 2024
1 parent 7c56901 commit bbebc21
Show file tree
Hide file tree
Showing 11 changed files with 2,321 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
return [
'enabled' => [
'title' => __('Enable/Disable', 'woocommerce'),
'label' => sprintf(__('Enable %s', 'ecpay-ecommerce-for-woocommerce'), $this->method_title),
'type' => 'checkbox',
'default' => 'no',
],
'title' => [
'title' => __('Title', 'woocommerce'),
'type' => 'text',
'default' => $this->method_title,
'description' => __('This controls the title which the user sees during checkout.', 'woocommerce'),
'desc_tip' => true,
],
'description' => [
'title' => __('Description', 'woocommerce'),
'type' => 'text',
'default' => $this->order_button_text,
'desc_tip' => true,
'description' => __('This controls the description which the user sees during checkout.', 'woocommerce'),
],
'min_amount' => [
'title' => __('A minimum order amount', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'number',
'default' => 3000,
'description' => __('The transaction amount must be at least NT$3,000.', 'ecpay-ecommerce-for-woocommerce'),
'custom_attributes' => [
'min' => 3000,
'step' => 1
]
],
'max_amount' => [
'title' => __('A maximum order amount', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'number',
'default' => 0,
'placeholder' => 0,
'description' => __('0 to disable maximum amount limit.', 'ecpay-ecommerce-for-woocommerce'),
'custom_attributes' => [
'min' => 0,
'step' => 1
]
]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
return [
'enabled' => [
'title' => __('Enable/Disable', 'woocommerce'),
/* translators: %s: Gateway method title */
'label' => sprintf(__('Enable %s', 'ecpay-ecommerce-for-woocommerce'), $this->method_title),
'type' => 'checkbox',
'default' => 'no',
],
'title' => [
'title' => __('Title', 'woocommerce'),
'type' => 'text',
'default' => $this->method_title,
'description' => __('This controls the title which the user sees during checkout.', 'woocommerce'),
'desc_tip' => true,
],
'description' => [
'title' => __('Description', 'woocommerce'),
'type' => 'text',
'default' => $this->order_button_text,
'desc_tip' => true,
'description' => __('This controls the description which the user sees during checkout.', 'woocommerce'),
],
'min_amount' => [
'title' => __('A minimum order amount', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'number',
'default' => 0,
'placeholder' => 0,
'description' => __('0 to disable minimum amount limit.', 'ecpay-ecommerce-for-woocommerce'),
'custom_attributes' => [
'min' => 0,
'step' => 1
]
],
'max_amount' => [
'title' => __('A maximum order amount', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'number',
'default' => 0,
'placeholder' => 0,
'description' => __('0 to disable maximum amount limit.', 'ecpay-ecommerce-for-woocommerce'),
'custom_attributes' => [
'min' => 0,
'step' => 1
]
],
'ecpay_dca' => [
'title' => __('DCA', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'ecpay_dca',
'default' => '',
'description' => '',
'desc_tip' => true,
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
return [
'enabled' => [
'title' => __('Enable/Disable', 'woocommerce'),
'label' => sprintf(__('Enable %s', 'ecpay-ecommerce-for-woocommerce'), $this->method_title),
'type' => 'checkbox',
'default' => 'no',
],
'title' => [
'title' => __('Title', 'woocommerce'),
'type' => 'text',
'default' => $this->method_title,
'description' => __('This controls the title which the user sees during checkout.', 'woocommerce'),
'desc_tip' => true,
],
'description' => [
'title' => __('Description', 'woocommerce'),
'type' => 'text',
'default' => $this->order_button_text,
'desc_tip' => true,
'description' => __('This controls the description which the user sees during checkout.', 'woocommerce'),
],
'min_amount' => [
'title' => __('A minimum order amount', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'number',
'default' => 0,
'placeholder' => 0,
'description' => __('0 to disable minimum amount limit.', 'ecpay-ecommerce-for-woocommerce'),
'custom_attributes' => [
'min' => 0,
'step' => 1
]
],
'max_amount' => [
'title' => __('A maximum order amount', 'ecpay-ecommerce-for-woocommerce'),
'type' => 'number',
'default' => 0,
'placeholder' => 0,
'description' => __('0 to disable maximum amount limit.', 'ecpay-ecommerce-for-woocommerce'),
'custom_attributes' => [
'min' => 0,
'step' => 1
]
]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

final class Wooecpay_Db_Process
{
/**
* 綠界模組資料庫版本,資料庫有異動時請更新
*
* @var string
*/
public static $ecpay_db_version = '1.0';

/**
* 資料庫處理程序
*
* @return void
*/
public static function ecpay_db_process() {
$site_option_ecpay_db_version = get_site_option('ecpay_db_version');

// 檢查綠界模組資料庫版本,若有差異則更新
if ($site_option_ecpay_db_version == NULL || $site_option_ecpay_db_version != self::$ecpay_db_version) {
self::create_db_table_ecpay_orders_payment_status();
}
}

/**
* 新增 Table - ecpay_orders_payment_status
*
* @return void
*/
protected static function create_db_table_ecpay_orders_payment_status() {
global $wpdb;

$table_name = $wpdb->prefix . 'ecpay_orders_payment_status';
$sql = "CREATE TABLE $table_name (
id bigint NOT NULL AUTO_INCREMENT,
order_id bigint NOT NULL,
payment_method varchar(60) NOT NULL,
merchant_trade_no varchar(60) NOT NULL DEFAULT '',
payment_status int(10) NOT NULL DEFAULT 0,
is_completed_duplicate int(1) NOT NULL DEFAULT 0,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
)";

self::modify_db_table($table_name, $sql);
}

/**
* 根據指定 SQL 異動資料庫
*
* @param string $table_name
* @param string $sql
* @return void
*/
protected static function modify_db_table($table_name, $sql) {
global $wpdb;

require_once(ABSPATH . '/wp-admin/includes/upgrade.php');

$isTableExists = $wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name;
$charset_collate = $isTableExists ? '' : $wpdb->get_charset_collate();

// 異動資料庫
$dbDelta_result = dbDelta($sql . $charset_collate . ";");

// 更新綠界模組資料庫版本紀錄
update_option('ecpay_db_version', self::$ecpay_db_version);
}
}
Loading

0 comments on commit bbebc21

Please sign in to comment.