Changeset 2988435
- Timestamp:
- 11/03/2023 10:40:35 AM (2 years ago)
- Location:
- ship-depot/trunk
- Files:
-
- 1 added
- 7 edited
-
Ship_Depot_init.php (modified) (1 diff)
-
helper/class-shipping-helper.php (added)
-
includes/Order/class-order-shipping.php (modified) (2 diffs)
-
includes/class-ship-depot-general.php (modified) (1 diff)
-
page/admin/orders/sd-order-detail.php (modified) (4 diffs)
-
page/frontend/sd-checkout-page.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
rest-api/class-shipdepot-webhook.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ship-depot/trunk/Ship_Depot_init.php
r2981538 r2988435 5 5 * Plugin URI: https://shipdepot.vn/ 6 6 * Description: Ship Depot support shipping couriers in Vietnam like GHN, GHTK, AhaMove. 7 * Version: 1.1. 27 * Version: 1.1.3 8 8 * Author: ShipDepot.vn 9 9 * Text Domain: ship-depot-translate -
ship-depot/trunk/includes/Order/class-order-shipping.php
r2963463 r2988435 19 19 * @param int $items_total_price Total price of all items in order. 20 20 * @param int $item_regular_price_total Total regular price of all items in order. 21 * @param int $order_total Price after calculate of order. 21 22 * @param string $for_courier Json of List courier calculate. 22 23 * @return Ship_Depot_Courier_Response[]|bool 23 24 */ 24 public static function calculate_shipping_fee($is_cod, $is_insurance, $insurance_amount, $list_packages, $list_items, $receiver, $sender_storage, $sender_info, $items_total_price, $item_regular_price_total, $ for_courier = '')25 public static function calculate_shipping_fee($is_cod, $is_insurance, $insurance_amount, $list_packages, $list_items, $receiver, $sender_storage, $sender_info, $items_total_price, $item_regular_price_total, $order_total, $for_courier = '') 25 26 { 26 27 Ship_Depot_Logger::wrlog('[Ship_Depot_Order_Shipping][calculate_shipping] receiver: ' . print_r($receiver, true)); … … 40 41 $cod = new Ship_Depot_Cod(); 41 42 $cod->IsActive = $is_cod; 42 $cod->Value = $is_cod ? $ items_total_price: 0;43 $cod->Value = $is_cod ? $order_total : 0; 43 44 44 45 $str_fee_modify = get_option('sd_setting_fee'); -
ship-depot/trunk/includes/class-ship-depot-general.php
r2963463 r2988435 51 51 require_once SHIP_DEPOT_DIR_PATH . 'helper/class-function-protect-data.php'; 52 52 require_once SHIP_DEPOT_DIR_PATH . 'helper/class-function-get-data.php'; 53 require_once SHIP_DEPOT_DIR_PATH . 'helper/class-shipping-helper.php'; 53 54 require_once SHIP_DEPOT_DIR_PATH . 'includes/Settings/class-ship-depot-data.php'; 54 55 require_once SHIP_DEPOT_DIR_PATH . 'rest-api/class-shipdepot-webhook.php'; -
ship-depot/trunk/page/admin/orders/sd-order-detail.php
r2981538 r2988435 287 287 "item_regular_price_total" => $item_regular_price_total, 288 288 "ship_from_station" => $ship_from_station, 289 "total_discount_amount" => $order->get_discount_total() 289 290 ); 290 291 … … 447 448 jQuery(document).ready(function($) { 448 449 let isAddNew = jQuery('#is_add_new').val() == "true" ? true : false; 449 let cod_amount = parseFloat(<?php echo esc_js( wc_get_order($order_id)->get_subtotal()) ?>);450 let cod_amount = parseFloat(<?php echo esc_js($order->get_subtotal() - floatval($order->get_discount_total())) ?>); 450 451 if ($('#selectedShipping').length > 0) { 451 452 console.log('selected shipping existed'); … … 740 741 { 741 742 //return []; 742 return ['sd_not_create_ship', 'sd_list_package_size', 'sd_sender_storage', 'sd_sender_info', 'sd_ship_info', 'sd_receiver', 'sd_insurance', 'sd_cod', 'sd_selected_shipping', 'sd_selected_courier', 'sd_shipping_notes', 'sd_customer_pay_shipping', 'sd_is_edit_order', 'sd_list_items', 'sd_cod_failed_info' ];743 return ['sd_not_create_ship', 'sd_list_package_size', 'sd_sender_storage', 'sd_sender_info', 'sd_ship_info', 'sd_receiver', 'sd_insurance', 'sd_cod', 'sd_selected_shipping', 'sd_selected_courier', 'sd_shipping_notes', 'sd_customer_pay_shipping', 'sd_is_edit_order', 'sd_list_items', 'sd_cod_failed_info', 'sd_ship_from_station']; 743 744 } 744 745 … … 885 886 $str_cod = get_post_meta($post->ID, 'sd_cod', true); 886 887 if (!Ship_Depot_Helper::check_null_or_empty($str_cod)) { 887 $cod = new Ship_Depot_ Insurance(Ship_Depot_Helper::CleanJsonFromHTMLAndDecode($str_cod));888 $cod = new Ship_Depot_Cod(Ship_Depot_Helper::CleanJsonFromHTMLAndDecode($str_cod)); 888 889 } 889 890 // -
ship-depot/trunk/page/frontend/sd-checkout-page.php
r2963463 r2988435 26 26 Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] _POST: ' . print_r($_POST, true)); 27 27 Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] _GET: ' . print_r($_GET, true)); 28 Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] cart get_total: ' . print_r(WC()->cart->get_total('number'), true)); 28 29 $str_courier_setting = get_option('sd_setting_courier'); 29 30 if (!Ship_Depot_Helper::check_null_or_empty($str_courier_setting)) { … … 148 149 Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] is_cod: ' . print_r($is_cod, true)); 149 150 // 150 $list_shipping = Ship_Depot_Order_Shipping::calculate_shipping_fee($is_cod, false, 0, $list_packages_sizes, $list_items, $receiver, isset($selected_storage) ? $selected_storage->WarehouseID : '', isset($sender_info) ? $sender_info : '', WC()->cart->get_subtotal(), $item_regular_price_total, $courier_setting);151 $list_shipping = Ship_Depot_Order_Shipping::calculate_shipping_fee($is_cod, false, 0, $list_packages_sizes, $list_items, $receiver, isset($selected_storage) ? $selected_storage->WarehouseID : '', isset($sender_info) ? $sender_info : '', WC()->cart->get_subtotal(), $item_regular_price_total, WC()->cart->get_total('number'), $courier_setting); 151 152 } 152 153 $str_selected_shipping = WC()->session->get('selected_shipping'); … … 489 490 } 490 491 //shipping notes 491 $shipping_notes = Ship_Depot_Helper::check_null_or_empty(sanitize_textarea_field($_POST['shipdepot_shipping_notes']) ? '' : sanitize_textarea_field($_POST['shipdepot_shipping_notes']));492 $shipping_notes = Ship_Depot_Helper::check_null_or_empty(sanitize_textarea_field($_POST['shipdepot_shipping_notes'])) ? '' : sanitize_textarea_field($_POST['shipdepot_shipping_notes']); 492 493 Ship_Depot_Logger::wrlog('[sd_action_checkout_order_processed] shipping_notes: ' . print_r($shipping_notes, true)); 493 494 update_post_meta($order_id, 'sd_shipping_notes', $shipping_notes); -
ship-depot/trunk/readme.txt
r2981538 r2988435 3 3 Tags: shipping, couriers, ghn, ghtk, aha 4 4 Requires at least: 6.1.1 5 Tested up to: 6.3. 15 Tested up to: 6.3.2 6 6 Requires PHP: 7.4.3 7 Stable tag: 1.1. 27 Stable tag: 1.1.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 65 65 66 66 == Changelog == 67 = 1.1.3 = 68 * Sửa 1 số lỗi nhỏ 67 69 68 70 = 1.1.2 = -
ship-depot/trunk/rest-api/class-shipdepot-webhook.php
r2922618 r2988435 51 51 'methods' => 'POST', 52 52 'callback' => [$this, 'sd_update_shipping_status'], 53 'permission_callback' => '__return_true' 54 ]); 55 56 register_rest_route('shipdepot/webhook/v1', '/UpdateCancelShipping', [ 57 'methods' => 'POST', 58 'callback' => [$this, 'sd_update_cancel_shipping'], 53 59 'permission_callback' => '__return_true' 54 60 ]); … … 228 234 && $shop_api_key == $data->APIKey 229 235 ) { 230 $ship_info = $data->ShipInfo;231 $ship_info_decrypted = Ship_Depot_ProtectData::DecryptData($ship_info );236 $ship_info_encrypted = $data->ShipInfo; 237 $ship_info_decrypted = Ship_Depot_ProtectData::DecryptData($ship_info_encrypted); 232 238 $ship_param = json_decode($ship_info_decrypted); 233 239 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_shipping_status] ship_param from post data: ' . print_r($ship_param, true)); … … 258 264 $str_update_order_statuses = get_option('sd_update_order_statuses'); 259 265 if (str_contains($status_lower, strtolower(SD_CANCEL_STATUS))) { 260 update_post_meta($ship_param->WOOOrderID, 'sd_ship_info', '');261 266 $order_note = __('Vận đơn ' . $ship_info->TrackingNumber . ' đã bị hủy. Lý do: ', 'ship-depot-translate'); 262 267 if (!Ship_Depot_Helper::check_null_or_empty($ship_param->CancelDescription)) { 263 268 $order_note = $order_note . ' ' . $ship_param->CancelDescription; 264 269 } 265 $order->add_order_note($order_note);270 Ship_Depot_Shipping_Helper::cancel_shipping($order, $ship_info->TrackingNumber, $order_note); 266 271 } 267 272 // … … 270 275 foreach ($list_update_order_statuses as $status_obj) { 271 276 $status = new Ship_Depot_Shipping_Status($status_obj); 272 if (str_contains($status_lower, strtolower($status->ID))){277 if (str_contains($status_lower, strtolower($status->ID))) { 273 278 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_shipping_status][update status auto] updated status in option: ' . print_r($status, true)); 274 if ($status->IsUsed && !Ship_Depot_Helper::check_null_or_empty($status->WooOrderStatusID)){279 if ($status->IsUsed && !Ship_Depot_Helper::check_null_or_empty($status->WooOrderStatusID)) { 275 280 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_shipping_status][update status auto] order status changed to ' . $status->WooOrderStatusID); 276 281 $order->update_status(str_replace('wc-', '', $status->WooOrderStatusID), 'Update auto by Ship Depot.'); … … 285 290 return 'OK'; 286 291 } 292 293 function sd_update_cancel_shipping($request) 294 { 295 $params = wp_parse_args($request->get_params(), ''); 296 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_cancel_shipping] params: ' . print_r($params, true)); 297 if (!Ship_Depot_Helper::check_null_or_empty($params)) { 298 $data = (object) $params; 299 $shop_api_key = get_option('sd_api_key'); 300 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_cancel_shipping] shop_api_key: ' . print_r($shop_api_key, true)); 301 if ( 302 !Ship_Depot_Helper::check_null_or_empty($shop_api_key) 303 && !Ship_Depot_Helper::check_null_or_empty($data->APIKey) 304 && $shop_api_key == $data->APIKey 305 ) { 306 $ship_info_encrypted = $data->ShipInfo; 307 $ship_info_decrypted = Ship_Depot_ProtectData::DecryptData($ship_info_encrypted); 308 $ship_param = json_decode($ship_info_decrypted); 309 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_cancel_shipping] ship_param from post data: ' . print_r($ship_param, true)); 310 $str_ship_info = get_post_meta($ship_param->WOOOrderID, 'sd_ship_info', true); 311 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_cancel_shipping] current ship_info: ' . print_r($str_ship_info, true)); 312 if (!Ship_Depot_Helper::check_null_or_empty($str_ship_info)) { 313 $ship_info = json_decode($str_ship_info); 314 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_cancel_shipping] ship_info->TrackingNumber: ' . print_r($ship_info->TrackingNumber, true)); 315 Ship_Depot_Logger::wrlog('[Ship_Depot_Webhook][sd_update_cancel_shipping] ship_info->TrackingNumber: ' . print_r($ship_param->TrackingNumber, true)); 316 if ($ship_info->TrackingNumber == $ship_param->TrackingNumber) { 317 $order = new WC_Order($ship_param->WOOOrderID); 318 //Update empty ship info 319 $order_note = __('Vận đơn ' . $ship_info->TrackingNumber . ' đã bị hủy. Lý do: ', 'ship-depot-translate'); 320 if (!Ship_Depot_Helper::check_null_or_empty($ship_param->CancelDescription)) { 321 $order_note = $order_note . ' ' . $ship_param->CancelDescription; 322 } 323 Ship_Depot_Shipping_Helper::cancel_shipping($order, $ship_info->TrackingNumber, $order_note); 324 // 325 } 326 } 327 } 328 } 329 return 'OK'; 330 } 287 331 } 288 332 new Ship_Depot_Webhook();
Note: See TracChangeset
for help on using the changeset viewer.