Plugin Directory

Changeset 3271879


Ignore:
Timestamp:
04/13/2025 06:04:03 PM (12 months ago)
Author:
cod24
Message:
  • Compatible with WP 6.8
  • Bugs fixes when creating new order in the admin
Location:
cod24-shipping
Files:
26 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • cod24-shipping/trunk/cod24-shipping.php

    r3267559 r3271879  
    33Plugin Name: COD24 Shipping For Woocommerce
    44Description: This plugin is adding COD24 shipping methods to woocommerce.
    5 Version: 4.0.4
     5Version: 4.0.5
    66Author: COD24
    77Author URI: https://cod24.ir
     
    2727        public function __construct()
    2828        {
    29             define('COD24_PLUGIN_VERSION', '4.0.4');
     29            define('COD24_PLUGIN_VERSION', '4.0.5');
    3030            define('COD24_PLUGIN_DIR', plugin_dir_path(__FILE__));
    3131            define('COD24_PLUGIN_URL', plugin_dir_url(__FILE__));
  • cod24-shipping/trunk/inc/class-cod24-woo.php

    r3257813 r3271879  
    66 * Package: COD24 Shipping
    77 * Author: COD24
    8  * Last Modified Time: 2025/03/18 16:02:43
     8 * Last Modified Time: 2025/04/07 15:06:48
    99 * License: GPL-2.0+
    1010 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4848            // order metabox & ajax handler
    4949            add_action( 'add_meta_boxes' , array( &$this , 'order_detail_metabox' ) );
    50             add_action( 'save_post_shop_order', array( &$this , 'save_order_cod24_fields' ) );
    5150            add_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_order_cod24_fields' ) );
    5251
     
    622621            }
    623622
     623            if( ! isset( $_POST['order_barcode_nonce'] ) ) {
     624                return;
     625            }
     626
    624627            $order = wc_get_order( $order_id );
    625628            $old_cod24_info = $order->get_meta('_cod24_info', true);
    626            
     629
     630            $total_weight = 0;
     631            if( !empty( $order->get_items() ) )
     632            {
     633                foreach ($order->get_items() as $item) {
     634                    if ($item['product_id'] > 0)
     635                    {
     636                        $quantity = $item['qty'];
     637                        $_product = $item->get_product();
     638                        if (!$_product->is_virtual()) {
     639                            $total_weight += ( floatval( $_product->get_weight() ) * absint( $quantity ) );
     640                        }
     641                    }
     642                }
     643            }
     644
    627645            $shipping_types = array( 'post', 'tipax' );
    628             if( in_array( $old_cod24_info['shipping_type'], $shipping_types ) )
     646            if( !empty( $old_cod24_info ) && isset( $old_cod24_info['shipping_type'] ) && ! empty( $old_cod24_info['shipping_type'] ) && in_array( $old_cod24_info['shipping_type'], $shipping_types ) && isset( $old_cod24_info['total_weight'] ) && ! empty( $old_cod24_info['total_weight'] ) && $old_cod24_info['total_weight'] > 0 )
    629647            {
    630648                $cod24_info = array();
    631649                $cod24_info['shipping_type'] = $old_cod24_info['shipping_type'];
     650                $cod24_info['total_weight'] = $total_weight;
    632651               
    633                 if( $old_cod24_info['shipping_type'] == 'post' )
     652                if( $old_cod24_info['shipping_type'] == 'post' && isset( $_POST['post_custom_total_weight'] ) && !empty( $_POST['post_custom_total_weight'] ) )
    634653                {
    635                    
    636654                    // check total weight
    637655                    $cod24_info['total_weight'] = floatval( sanitize_text_field( $_POST['post_custom_total_weight'] ) );
     
    657675                    }
    658676                }
    659                 elseif( $old_cod24_info['shipping_type'] == 'tipax' )
     677                elseif( $old_cod24_info['shipping_type'] == 'tipax' && isset( $_POST['tipax_custom_total_weight'] ) && !empty( $_POST['tipax_custom_total_weight'] ) )
    660678                {
    661679                    // check total weight
     
    717735                $order->update_meta_data( '_cod24_info', $cod24_info );
    718736                $order->save();
     737            }
     738            else
     739            {
     740                $cod24_info = array(
     741                    'total_weight' => ( $total_weight > 0 ) ? $total_weight : '',
     742                    'shipping_type' => 'post',
     743                    'serial' => '',
     744                    'barcode' => '',
     745                    'data' => ''
     746                );
     747               
     748                $order->update_meta_data( '_cod24_info', $cod24_info );
     749                $order->save();
    719750            }
    720751        }
  • cod24-shipping/trunk/readme.txt

    r3267559 r3271879  
    33Tags: cod24, iran shipping, tipax, woocommerce shipping, shipping method
    44Requires at least: 5.0
    5 Tested up to: 6.7
    6 Stable tag: 4.0.4
     5Tested up to: 6.8
     6Stable tag: 4.0.5
    77License: GPL-2.0+
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4343
    4444== Changelog ==
     45
     46= 4.0.5 =
     47* Compatible with WP 6.8
     48* Bugs fixes when creating new order in the admin
    4549
    4650= 4.0.4 =
Note: See TracChangeset for help on using the changeset viewer.