Plugin Directory

Changeset 3166359


Ignore:
Timestamp:
10/10/2024 09:07:30 AM (17 months ago)
Author:
shipdepot
Message:

Update version 1.2.18

Location:
ship-depot/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ship-depot/trunk/Ship_Depot_init.php

    r3090663 r3166359  
    55 * Plugin URI:        https://shipdepot.vn/
    66 * Description:       Ship Depot support shipping couriers in Vietnam like GHN, GHTK, AhaMove.
    7  * Version:           1.2.17
     7 * Version:           1.2.18
    88 * Author:            ShipDepot.vn
    99 * Text Domain:       ship-depot-translate
     
    3535
    3636if (!defined('SHIP_DEPOT_VERSION')) {
    37     define('SHIP_DEPOT_VERSION', '1.2.17');
     37    define('SHIP_DEPOT_VERSION', '1.2.18');
    3838}
    3939
  • ship-depot/trunk/includes/Model/class-item.php

    r3063365 r3166359  
    99        public string $Name = "";
    1010        public string $ImageURL = "";
    11         public int $Quantity = 0;
    1211        public int $Price = 0;
    1312        public int $TotalPrice = 0;
  • ship-depot/trunk/includes/Model/class-package.php

    r3063365 r3166359  
    99        public float $Height = 0;
    1010        public float $Weight = 0;
     11        public int $Quantity = 1;
    1112        function __construct($object = null)
    1213        {
  • ship-depot/trunk/page/admin/orders/sd-order-list.php

    r3090008 r3166359  
    9797    wp_add_inline_style('woocommerce_admin_styles', "table.wp-list-table .column-sd-shipping-status{ width: 16%; }");
    9898}
     99
     100
     101
     102
  • ship-depot/trunk/page/frontend/sd-checkout-page.php

    r3090663 r3166359  
    4040// Disable all payment gateways on the checkout page and replace the "Pay" button with "Place order".
    4141//add_filter('woocommerce_cart_needs_payment', '__return_false');
    42 
    4342
    4443//Current hook: woocommerce_review_order_before_order_total => after list item
     
    6766        foreach ($list_cart_items as $item) {
    6867            //Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] item: ' . print_r($item, true));
    69             Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] item qty: ' . print_r($item['quantity'], true));
    70             $total_qty += floatval($item['quantity']);
     68            $item_quantity = floatval($item['quantity']);
     69            Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] item qty: ' . print_r($item_quantity, true));
     70            $total_qty += $item_quantity;
    7171            $product = $item['data'];
    7272            $product_data = $product->get_data();
     73
    7374            //Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] product_data: ' . print_r($product_data, true));
    7475            $package_size = new Ship_Depot_Package();
     
    7677            $package_size->Width = isset($product_data['width']) ? Ship_Depot_Helper::ConvertToShipDepotDimension($product_data['width']) : 0;
    7778            $package_size->Height = isset($product_data['height']) ? Ship_Depot_Helper::ConvertToShipDepotDimension($product_data['height']) : 0;
    78             $package_size->Weight = isset($product_data['weight']) ? Ship_Depot_Helper::ConvertToShipDepotWeight($product_data['weight']) : 0;
    79 
     79            $package_size->Weight = isset($product_data['weight']) ? Ship_Depot_Helper::ConvertToShipDepotWeight($product_data['weight']) * $item_quantity : 0;
     80            $package_size->Quantity = 1;
     81            //Update 1.2.18: calculate package size with quantity
     82            if ($item_quantity > 1) {
     83                $min_value = min($package_size->Length, $package_size->Width, $package_size->Height);
     84                if ($min_value == $package_size->Width) {
     85                    $package_size->Width = $package_size->Width * $item_quantity;
     86                } else if ($min_value == $package_size->Length) {
     87                    $package_size->Length = $package_size->Length * $item_quantity;
     88                } else {
     89                    $package_size->Height = $package_size->Height * $item_quantity;
     90                }
     91            }
     92            Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] package_size: ' . print_r($package_size, true));
    8093            $it = new Ship_Depot_Item();
    8194            $it->Sku = $product_data['sku'];
    8295            $it->ID = $item['product_id'];
    8396            $it->Name = $product_data['name'];
    84             $it->Quantity = $item['quantity'];
     97            $it->Quantity = $item_quantity;
    8598            $it->TotalPrice = $item['line_total'];
    8699            $it->Length = isset($product_data['length']) ? Ship_Depot_Helper::ConvertToShipDepotDimension($product_data['length']) : 0;
     
    92105            $item_regular_price_total += floatval($regular_price) * floatval($item['quantity']);
    93106            $it->RegularPrice = $regular_price;
    94             // Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] it: ' . print_r($it, true));
     107            Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] it: ' . print_r($it, true));
    95108            //
    96109            array_push($list_packages_sizes, $package_size);
     
    450463        $order = wc_get_order($order_id);
    451464    }
    452     //$order = wc_get_order($order_id);
    453465    //Set shipping item
    454466    $shippings = $order->get_items('shipping');
     
    485497        $product = $item_product->get_product();
    486498        // Ship_Depot_Logger::wrlog('[sd_action_checkout_order_processed] product: ' . print_r($product, true));
    487         // $item_product = new WC_Order_Item_Product($item);
    488         // $product = new WC_Product($item_product->get_product_id());
     499        $item_quantity = $item->get_quantity();
    489500
    490501        $package_size = new Ship_Depot_Package();
     
    492503        $package_size->Width = Ship_Depot_Helper::ConvertToShipDepotDimension($product->get_width());
    493504        $package_size->Height = Ship_Depot_Helper::ConvertToShipDepotDimension($product->get_height());
    494         $package_size->Weight = Ship_Depot_Helper::ConvertToShipDepotWeight($product->get_weight());
     505        $package_size->Weight = Ship_Depot_Helper::ConvertToShipDepotWeight($product->get_weight()) * $item_quantity;
     506        $package_size->Quantity = 1;
     507        //Update 1.2.18: calculate package size with quantity
     508        if ($item_quantity > 1) {
     509            $min_value = min($package_size->Length, $package_size->Width, $package_size->Height);
     510            if ($min_value == $package_size->Width) {
     511                $package_size->Width = $package_size->Width * $item_quantity;
     512            } else if ($min_value == $package_size->Length) {
     513                $package_size->Length = $package_size->Length * $item_quantity;
     514            } else {
     515                $package_size->Height = $package_size->Height * $item_quantity;
     516            }
     517        }
    495518        array_push($list_packages_sizes, $package_size);
    496519    }
  • ship-depot/trunk/readme.txt

    r3090663 r3166359  
    33Tags: shipping, couriers, ghn, ghtk, aha
    44Requires at least: 6.1.1
    5 Tested up to: 6.4.3
     5Tested up to: 6.6.2
    66Requires PHP: 7.4.3
    7 Stable tag: 1.2.17
     7Stable tag: 1.2.18
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6565
    6666== Changelog ==
     67= 1.2.18 =
     68* Sửa lỗi tính phí vận chuyển ở trang thanh toán.
     69
    6770= 1.2.17 =
    6871* Sửa một số lỗi nhỏ.
    69 
    7072
    7173= 1.2.16 =
Note: See TracChangeset for help on using the changeset viewer.