Changeset 2471669
- Timestamp:
- 02/09/2021 02:09:31 PM (5 years ago)
- Location:
- cse-delivery/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (1 diff)
-
cse-delivery.php (modified) (2 diffs)
-
includes/WCShippingCSE.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cse-delivery/trunk/README.txt
r2446694 r2471669 46 46 = 1.0.1 = 47 47 * Исправление ошибок 48 = 1.0.2 = 49 * Конвертация величин при расчете стоимости -
cse-delivery/trunk/cse-delivery.php
r2446694 r2471669 3 3 /** 4 4 * @link https://cse.ru 5 * @since 1.0. 15 * @since 1.0.2 6 6 * @package CSEDelivery 7 7 * … … 10 10 * Plugin URI: www.cse.ru 11 11 * Description: Модуль интеграции со службой доставки Курьер Сервис Экспресс: расчет стоимости доставки, формирование накладных и заказов на доставку, отслеживание грузов и получение статистики 12 * Version: 1.0. 112 * Version: 1.0.2 13 13 * Author: CSE 14 14 * Author URI: https://cse.ru -
cse-delivery/trunk/includes/WCShippingCSE.php
r2446694 r2471669 19 19 */ 20 20 public function __construct( $instance_id = 0 ) { 21 22 parent::__construct($instance_id); 23 21 24 $this->id = 'cse'; 22 $this->instance_id = absint( $instance_id );23 25 $this->method_title = "Доставка КСЕ"; 24 26 $this->title = "Доставка КСЕ"; … … 58 60 59 61 foreach ( $package['contents'] as $content ) { 62 63 $convertRate = $this->getConvertRate(); 64 60 65 /** @var $product WC_Product */ 61 66 $product = $content['data']; 62 $productWeight = ! empty( $product->get_weight() ) ? $product->get_weight() : $this->options['wc_cse_weight'] ?? 0;67 $productWeight = ! empty( $product->get_weight() ) ? ($product->get_weight() * $convertRate['weight']) : $this->options['wc_cse_weight'] ?? 0; 63 68 $quantity = $content["quantity"]; 64 69 65 $width = ! empty( $product->get_width() ) ? $product->get_width(): 0;66 $height = ! empty( $product->get_height() ) ? $product->get_height() : 0;67 $length = ! empty( $product->get_length() ) ? $product->get_length() : 0;70 $width = ! empty( $product->get_width() ) ? ($product->get_width() * $convertRate['length']): 0; 71 $height = ! empty( $product->get_height() ) ? ($product->get_height() * $convertRate['length']) : 0; 72 $length = ! empty( $product->get_length() ) ? ($product->get_length() * $convertRate['length']) : 0; 68 73 69 74 $volumeWeight = round( ( ( floatval( $width ) * floatval( $height ) * floatval( $length ) ) / 5000 ) * $quantity, 2 ); … … 137 142 return $result < 0 ? 0 : $result; 138 143 } 144 145 private function getConvertRate() { 146 147 $weightUnit = get_option( 'woocommerce_weight_unit' ); 148 $dimensionUnit = get_option( 'woocommerce_dimension_unit' ); 149 150 switch ( $weightUnit ) { 151 case 'g': 152 $weightRate = 0.001; 153 break; 154 default: 155 $weightRate = 1; 156 } 157 158 switch ( $dimensionUnit ) { 159 case 'm': 160 $dimensionRate = 100; 161 break; 162 default: 163 $dimensionRate = 1; 164 } 165 166 return [ 167 'length' => $dimensionRate, 168 'weight' => $weightRate, 169 ]; 170 } 139 171 }
Note: See TracChangeset
for help on using the changeset viewer.