Changeset 3343366
- Timestamp:
- 08/12/2025 08:56:36 AM (5 months ago)
- Location:
- shiperman-for-woocommerce/trunk
- Files:
-
- 6 edited
-
changelog.txt (modified) (1 diff)
-
includes/Admin/class-shiperman-admin.php (modified) (2 diffs)
-
includes/Admin/class-shiperman-product-validation.php (modified) (3 diffs)
-
includes/class-shiperman-shipping-method.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
-
shiperman-for-woocommerce.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
shiperman-for-woocommerce/trunk/changelog.txt
r3275398 r3343366 1 1 *** WooCommerce Shiperman Changelog *** 2 3 2025-08-07 - version 1.4.1 4 * Fixed Product edit issue. 5 * Automatically assign a default weight of 1 kg when a product without defined weight is added to the cart. 6 * Added admin notice on WooCommerce Orders page regarding default shipment weight. 2 7 3 8 2025-04-16 - version 1.2.0 -
shiperman-for-woocommerce/trunk/includes/Admin/class-shiperman-admin.php
r3281126 r3343366 39 39 40 40 add_action('admin_notices', [$this, 'check_configuration_notice']); 41 42 add_action('admin_notices', [$this, 'display_admin_notice_order_page'] ); 41 43 } 42 44 … … 1280 1282 return "$pdf_url/{$tracking_number}_{$reference_id}.pdf"; 1281 1283 } 1282 } 1284 1285 /** 1286 * Display an admin notice on the WooCommerce Orders page. 1287 */ 1288 public function display_admin_notice_order_page() { 1289 global $pagenow; 1290 // Check if it's the WooCommerce order edit page 1291 if ( $pagenow === 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] === 'shop_order' || $pagenow === 'admin.php' && isset($_GET['page']) && $_GET['page'] === 'wc-orders' ) { 1292 echo '<div class="notice notice-error"><p style="color:red;"><strong>Note:</strong> Please enter the shipemnt weight. If left blank, a default value of 1 kg will be applied. Once the actual weight is verified, the charge will be adjusted accordingly to reflect the correct amount.</p></div>'; 1293 } 1294 } 1295 } -
shiperman-for-woocommerce/trunk/includes/Admin/class-shiperman-product-validation.php
r3242749 r3343366 16 16 { 17 17 18 if (!isset($_POST['woocommerce_meta_nonce']) || !check_admin_referer('woocommerce_process_product_meta', 'woocommerce_meta_nonce')) {18 /*if (!isset($_POST['woocommerce_meta_nonce']) || !check_admin_referer('woocommerce_process_product_meta', 'woocommerce_meta_nonce')) { 19 19 wp_die(esc_html__('Invalid nonce verification.', 'shiperman-for-woocommerce')); 20 } 20 }*/ 21 21 22 22 23 if (!$this->is_shiperman_enabled()) { … … 34 35 $height = isset($_POST['_height']) ? sanitize_text_field(wp_unslash($_POST['_height'])) : ''; 35 36 36 if ( empty($weight) ||empty($length) || empty($width) || empty($height)) {37 if ( empty($length) || empty($width) || empty($height)) { 37 38 $this->add_admin_notice(); 38 39 39 40 // Prevent saving by triggering an error 40 41 //remove_action('save_post_product', [$this, 'validate_product_dimensions'], 10); 41 wp_die(esc_html__('Please ensure weight,length, width, and height are set for this product when Shiperman shipping is enabled.', 'shiperman-for-woocommerce'));42 wp_die(esc_html__('Please ensure length, width, and height are set for this product when Shiperman shipping is enabled.', 'shiperman-for-woocommerce')); 42 43 } 43 44 } … … 57 58 }); 58 59 } 60 59 61 } -
shiperman-for-woocommerce/trunk/includes/class-shiperman-shipping-method.php
r3281024 r3343366 18 18 $this->title = "Shiperman Shipping"; 19 19 20 21 $this->enabled = "yes"; 20 22 // Check if there are any products missing shipping info 21 $missing_info = $this->get_products_missing_shipping_info();22 23 if (!empty($missing_info)) {24 // Disable the method25 $this->enabled = "no";26 // Optional: Add admin notice27 // add_action('admin_notices', [$this, 'admin_notice_invalid_products']);28 } else {29 $this->enabled = "yes";30 }23 //$missing_info = $this->get_products_missing_shipping_info(); 24 25 // if (!empty($missing_info)) { 26 // // Disable the method 27 // $this->enabled = "no"; 28 // // Optional: Add admin notice 29 // // add_action('admin_notices', [$this, 'admin_notice_invalid_products']); 30 // } else { 31 // $this->enabled = "yes"; 32 // } 31 33 32 34 $this->init(); … … 53 55 if (! $this->is_product_shipping_info_valid($product)) { 54 56 $invalid_products[] = $product; 57 55 58 } 56 59 } … … 61 64 private function is_product_shipping_info_valid($product) 62 65 { 63 return (float) $product->get_weight() > 0 && 64 (float) $product->get_length() > 0 && 66 // Allow products with missing weight (will use default 1kg) 67 // Only require length, width, and height to be valid 68 return (float) $product->get_length() > 0 && 65 69 (float) $product->get_width() > 0 && 66 70 (float) $product->get_height() > 0; … … 145 149 $cost = ($pricing_type === 'flat_rate') ? (float) $this->get_option('flat_rate_cost') : $this->get_dynamic_shipping_rate($package); 146 150 151 $margin = ($pricing_type === 'margin_rate') ? (float) $this->get_option('margin_rate') : $this->get_dynamic_shipping_rate($package); 152 if ($margin) { 153 $cost = $cost * $margin; 154 } 155 147 156 if (WC()->cart->get_cart_contents_total() >= $this->get_option('free_shipping_threshold')) { 148 157 $cost = 0; … … 164 173 $product = $item['data']; 165 174 $quantity = $item['quantity']; 175 176 // Use default weight if missing 177 $weight = (float) $product->get_weight(); 178 if ($weight <= 0) { 179 $weight = 1.0; // Default 1kg 180 // Set flag to show notice 181 WC()->session->set('shiperman_default_weight_applied', true); 182 } 166 183 167 184 for ($i = 0; $i < $quantity; $i++) { … … 170 187 'name' => $product->get_name(), 171 188 'price' => (float) $product->get_price(), 172 'weight' => (float) $product->get_weight(),189 'weight' => $weight, // Use calculated weight 173 190 'length' => (float) $product->get_length(), 174 191 'width' => (float) $product->get_width(), … … 206 223 public function process_admin_options() 207 224 { 208 $missing_info = $this->get_products_missing_shipping_info();225 /*$missing_info = $this->get_products_missing_shipping_info(); 209 226 if (!empty($missing_info)) { 210 227 // Force-disable and show message … … 214 231 add_action('admin_notices', function () { 215 232 echo '<div class="notice notice-error is-dismissible">'; 216 echo '<p>' . esc_html__('Shiperman Shipping cannot be enabled until all physical products have valid shipping data.', 'shiperman-for-woocommerce') . '</p>';233 echo '<p>' . esc_html__('Shiperman Shipping cannot be enabled until all physical products have valid length, width, and height. Weight will use default 1kg if not set.', 'shiperman-for-woocommerce') . '</p>'; 217 234 echo '<p><a href="' . esc_url(admin_url('admin.php?page=shiperman_validate_shop_tools')) . '" class="button button-primary">'; 218 235 echo esc_html__('Validate Products Now', 'shiperman-for-woocommerce'); … … 223 240 224 241 return; // Don't save options 225 } 242 }*/ 226 243 227 244 parent::process_admin_options(); 228 245 } 246 229 247 } -
shiperman-for-woocommerce/trunk/readme.txt
r3281024 r3343366 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.4 8 Stable tag: 1.4. 08 Stable tag: 1.4.1 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 68 68 == Changelog == 69 69 70 = 1.4.1 = 71 * Fixed Product edit issue. 72 * Automatically assign a default weight of 1 kg when a product without defined weight is added to the cart. 73 * Added admin notice on WooCommerce Orders page regarding default shipment weight. 74 70 75 = 1.4.0 = 71 76 * Added "Settings" & "Set Pricing" Menus For Easy Navigation. … … 114 119 == Upgrade Notice == 115 120 121 = 1.4.1 = 122 * Mandatory update. 123 116 124 = 1.4.0 = 117 125 * Mandatory update. -
shiperman-for-woocommerce/trunk/shiperman-for-woocommerce.php
r3281024 r3343366 3 3 Plugin Name: Shiperman for WooCommerce 4 4 Description: Integrates Shiperman shipping services into WooCommerce with real-time rate calculations and flexible rate configurations. 5 Version: 1. 3.25 Version: 1.4.1 6 6 Author: Shiperman 7 7 Author URI: https://shiperman.com
Note: See TracChangeset
for help on using the changeset viewer.