Skip to content

Commit 93dcb45

Browse files
committed
update
1 parent 49acca4 commit 93dcb45

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

wc-settings.php

+21
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,32 @@ function mxp_check_checkout_post_data() {
823823
}
824824
add_action('woocommerce_checkout_process', 'mxp_check_checkout_post_data');
825825

826+
// 密碼強度改不建議
826827
function mxp_min_password_strength($strength) {
827828
return 0;
828829
}
829830
add_filter('woocommerce_min_password_strength', 'mxp_min_password_strength', 99, 1);
830831

832+
// 後台支援搜尋包含 SKU 貨號的訂單
833+
function mxp_order_search_by_sku($order_ids, $term, $search_fields) {
834+
global $wpdb;
835+
if (!empty($term)) {
836+
// 確認有沒有這個商品,沒有就跳開了
837+
$product_id = wc_get_product_id_by_sku($wpdb->esc_like(wc_clean($term)));
838+
if (!$product_id) {
839+
return $order_ids;
840+
}
841+
// 找找看關聯資料,輸出不重複的訂單編號
842+
$order_ids = array_unique(
843+
$wpdb->get_col(
844+
$wpdb->prepare("SELECT order_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key IN ( '_product_id', '_variation_id' ) AND meta_value = %d ) AND order_item_type = 'line_item'", $product_id)
845+
)
846+
);
847+
}
848+
return $order_ids;
849+
}
850+
add_filter('woocommerce_shop_order_search_results', 'mxp_order_search_by_sku', 9999, 3);
851+
831852
// function mxp_woocommerce_ecpay_available_payment_gateways($available_gateways) {
832853
// // 判斷是否選取綠界物流,是的話取消「貨到付款」的選項避免錯誤。(此為超商取貨(無付款)功能處理)
833854
// $sm = null;

0 commit comments

Comments
 (0)