Plugin Directory

Changeset 3311966


Ignore:
Timestamp:
06/15/2025 05:00:07 PM (10 months ago)
Author:
advshipmgr
Message:

Version update to 1.4

Location:
asm-manager
Files:
10 added
12 edited

Legend:

Unmodified
Added
Removed
  • asm-manager/tags/1.4/asmplsww.php

    r3303095 r3311966  
    66  Author: ASM
    77  Developer: ASM
    8   Version: 1.4
     8  Version: 1.4.0
    99  WC requires at least: 7.0.0
    1010  WC tested up to: 9.8
     
    2222
    2323// Check for outdated installs or first-time upgrades from older versions
    24 add_action('plugins_loaded', 'asmplsww_enforce_version');
    25 function asmplsww_enforce_version() {
    26     $stored_version = get_option('asm_version');
     24add_action('admin_notices', 'asmplsww_always_show_warning');
    2725
    28     if (!$stored_version) {
    29         // User came from v1.3 or earlier (no version info)
    30         add_action('admin_notices', 'asmplsww_force_update_notice');
    31         // Optional: disable core plugin functionality here
    32         add_filter('option_active_plugins', function($plugins) {
    33             deactivate_plugins(plugin_basename(__FILE__));
    34             return $plugins;
    35         });
    36         return;
    37     }
    38 
    39     if (version_compare($stored_version, ASMPLSWW_VERSION, '<')) {
    40         update_option('asm_version', ASMPLSWW_VERSION);
    41     }
     26function asmplsww_always_show_warning() {
     27       echo '<div class="notice notice-error"><p><strong>Advanced Shipping Manager:</strong> Please update to version 1.4.0 to continue using the plugin.  IMPORTANT!  PLEASE CONTACT US BEFORE UPDATING @ 888-546-4932 OR SUPPORT@ADVANCEDSHIPPINGMANAGER.COM.</p></div>';
    4228}
    4329
    44 function asmplsww_force_update_notice() {
    45     echo '<div class="notice notice-error"><p><strong>IMPORTANT!</strong> This version requires an update in our database for existing stores.  Please contact us BEFORE updating it at 888-546-4932.</p></div>';
    46 }
    4730
    4831// Set version on activation
     
    157140
    158141        // Send the email
    159         wp_mail($to, $subject, $body, $headers);
     142        // wp_mail($to, $subject, $body, $headers);
    160143
    161144        wp_send_json_success('Feedback sent successfully.');
  • asm-manager/tags/1.4/changelog.txt

    r3303095 r3311966  
    11== Changelog ==
    22= 1.4.0 =
    3 * MAJOR UPDATE!
     3* MAJOR UPDATE!  IF YOU ARE UPDATING FROM 1.3 - PLEASE CONTACT US FIRST at 888-546-4932
    44* Embedded admin access
    55* Export/Import functionality added.
  • asm-manager/tags/1.4/includes/asmplsww_xml_data.php

    r3303095 r3311966  
    3131
    3232    public static function asm_plugin_activation() {
     33
     34            $host = $_SERVER['HTTP_HOST'] ?? '';
     35            $server_addr = $_SERVER['SERVER_ADDR'] ?? '';
     36
     37            if (
     38                strpos($host, 'localhost') !== false ||
     39                strpos($host, '127.0.0.1') !== false ||
     40                $server_addr === '127.0.0.1'
     41            ) {
     42                // Show error and block activation
     43                deactivate_plugins(plugin_basename(__FILE__));
     44                wp_die(
     45                    'Please note: ASM must be installed on a live website. Installation on localhost or 127.0.0.1 environments is not supported.',
     46                    'Activation Blocked',
     47                    array('back_link' => true)
     48                );
     49            }
    3350
    3451        $instance = new self();
  • asm-manager/tags/1.4/readme.txt

    r3303095 r3311966  
    7474== Changelog ==
    7575= 1.4.0 =
    76 * MAJOR UPDATE!
     76* MAJOR UPDATE!  IF YOU ARE UPDATING FROM 1.3 - PLEASE CONTACT US FIRST at 888-546-4932
    7777* Embedded admin access
    7878* Export/Import functionality added.
  • asm-manager/trunk/asmplsww.php

    r3303098 r3311966  
    66  Author: ASM
    77  Developer: ASM
    8   Version: 1.3
     8  Version: 1.4.0
    99  WC requires at least: 7.0.0
    1010  WC tested up to: 9.8
    1111  Author URI: https://www.advancedshippingmanager.com
     12  Text Domain: asmplsww
    1213 */
    1314
    14 if (!defined('ABSPATH')) {
    15     exit; // Exit if accessed directly
     15
     16if (!defined('ABSPATH')) exit;
     17define('ASMPLSWW_VERSION', '1.4.0'); // Version tracking
     18define('ASMPLSWW', "https://www.advancedshippingmanager.com");
     19define('ASMPLSWWSERVICE', ASMPLSWW."/clients/web_services/asm_web_service.php");
     20define('ASMPLSWWCLIENT', ASMPLSWW."/clients/admin/index.php");
     21
     22
     23// Check for outdated installs or first-time upgrades from older versions
     24add_action('admin_notices', 'asmplsww_always_show_warning');
     25
     26function asmplsww_always_show_warning() {
     27       echo '<div class="notice notice-error"><p><strong>Advanced Shipping Manager:</strong> Please update to version 1.4.0 to continue using the plugin.  IMPORTANT!  PLEASE CONTACT US BEFORE UPDATING @ 888-546-4932 OR SUPPORT@ADVANCEDSHIPPINGMANAGER.COM.</p></div>';
    1628}
    1729
    18 if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
    1930
    20     if (!class_exists('ASMPLSWW_Admin')) {
    21         include_once 'includes/asmplsww_admin_field.php';
     31// Set version on activation
     32register_activation_hook(__FILE__, ['Aadvance_Shipping_Plugin', 'asmplsww_set_plugin_version_on_activation']);
     33
     34
     35
     36
     37require_once plugin_dir_path(__FILE__) . 'asmplsww-settings.php';
     38
     39// Register plugin activation and deactivation hooks
     40register_activation_hook(__FILE__, ["ASM_Store_Creator", 'asm_plugin_activation']);
     41register_deactivation_hook(__FILE__, ["ASM_Store_Creator", 'asm_plugin_deactivation']);
     42
     43
     44class Aadvance_Shipping_Plugin {
     45
     46    public function __construct() {
     47        add_action('admin_init', array($this, 'runtime_check_woocommerce'));
     48
     49        add_action('before_woocommerce_init', function() {
     50            if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
     51                \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
     52                    'custom_order_tables',
     53                    __FILE__,
     54                    true
     55                );
     56            }
     57        });
     58
     59        include_once plugin_dir_path(__FILE__) . 'includes/asmplsww_shipping_method_declear.php';
     60        add_action('admin_enqueue_scripts', [$this, 'asm_enqueue_assets']);
     61        add_action('wp_enqueue_scripts', [$this, 'asm_enqueue_plugin_scripts']);
     62        add_action('wp_ajax_submit_deactivation_feedback', [$this, 'submit_deactivation_feedback']);
    2263    }
    2364
    24     // Asm Shipping Method Loading
    25     if (!class_exists('ASMPLSWW_Shipping_Method')) {
    26         include_once 'includes/asmplsww_shipping_method.php';
     65    public function asm_enqueue_assets($hook) {
     66        if ($this->asm_is_shipping_settings_page()) {
     67            wp_enqueue_style('asm-css', plugin_dir_url(__FILE__) . 'assets/css/asm.css', [], '1.0');
     68        }
     69// new add
     70        // if ($hook !== 'plugins.php')
     71        //  return;
     72
     73        wp_enqueue_style('asm-admin', plugin_dir_url(__FILE__) . 'assets/css/asm-admin.css', [], '1.0');
     74        wp_enqueue_script('asm_admin_script',plugin_dir_url(__FILE__) . 'assets/js/asm-admin.js',['jquery'],'1.0.0',true);
     75        wp_localize_script('asm_admin_script', 'asm_vars', ['ajax_url'=> admin_url('admin-ajax.php'),'plugin_slug' => plugin_basename(__FILE__)]);
     76// new add
     77
     78    }
     79    public function asm_enqueue_plugin_scripts() {
     80        // Enqueue your custom JS
     81        wp_enqueue_script('asm_plugin_script',plugin_dir_url(__FILE__) . 'assets/js/asm-script.js',['jquery'],'1.0.0',true);
     82        // Localize your PHP data
     83        wp_localize_script('asm_plugin_script', 'asm_vars', ['ajax_url'=> admin_url('admin-ajax.php'),'nonce'=> wp_create_nonce('asm_nonce'),'some_message' => __('Shipping updated!', 'asm'),]);
    2784    }
    2885
    29     add_action('woocommerce_shipping_init', 'asmplsww_shipping_method_init');
    30 
    31     function asmplsww_shipping_method_add($methods)
    32     {
    33         $methods['asmplsww'] = 'ASMPLSWW_Shipping_Method';
    34         return $methods;
     86    private function asm_is_shipping_settings_page() {
     87        return isset($_GET['page']) && $_GET['page'] === 'shipping-settings';
    3588    }
    3689
    37     add_filter('woocommerce_shipping_methods', 'asmplsww_shipping_method_add');
     90   
     91    public static function activation_check_static() {
     92        $plugin = new self();
     93        $plugin->activation_check();
     94    }
    3895
    39     add_action( 'before_woocommerce_init', function() {
    40     if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    41         \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
    42     }
    43     });
     96    public function activation_check() {
     97        if (!$this->is_woocommerce_active()) {
     98            deactivate_plugins(plugin_basename(__FILE__));
     99            wp_die('This plugin requires WooCommerce to be installed and active.', 'Plugin dependency check', ['back_link' => true]);
     100        }
     101    }
    44102
     103    public function runtime_check_woocommerce() {
     104        if (!$this->is_woocommerce_active()) {
     105            deactivate_plugins(plugin_basename(__FILE__));
     106            add_action('admin_notices', [$this, 'show_wc_required_notice']);
     107        }
     108    }
     109
     110    public function show_wc_required_notice() {
     111        echo '<div class="notice notice-error is-dismissible"><p><strong>Advanced Shipping Manager</strong> has been deactivated because WooCommerce is not active.</p></div>';
     112    }
     113
     114    private function is_woocommerce_active() {
     115        include_once(ABSPATH . 'wp-admin/includes/plugin.php');
     116        return is_plugin_active('woocommerce/woocommerce.php') || class_exists('WooCommerce');
     117    }
     118
     119    public function submit_deactivation_feedback() {
     120        if (!current_user_can('activate_plugins')) {
     121            wp_send_json_error('Unauthorized', 403);
     122        }
     123        $reasons = [];
     124
     125        if ( isset( $_POST['reasons'] ) && is_array( $_POST['reasons'] ) ) {
     126            $reasons = array_map( 'sanitize_text_field', wp_unslash( $_POST['reasons'] ) );
     127        }
     128       
     129        $domain  = home_url(); // Gets the site URL
     130        $user    = wp_get_current_user();
     131
     132        // Format email
     133        $to      = 'support@advancedshippingmanager.com';
     134        $subject = 'Plugin Deactivation Feedback';
     135        $body    = "ASM plugin was deactivated on: {$domain}\n\n";
     136        $body   .= "Deactivated by: {$user->user_email}\n\n";
     137        $body   .= "Reason(s):\n" . implode("\n", array_map('sanitize_text_field', $reasons));
     138
     139        $headers = ['Content-Type: text/plain; charset=UTF-8'];
     140
     141        // Send the email
     142        // wp_mail($to, $subject, $body, $headers);
     143
     144        wp_send_json_success('Feedback sent successfully.');
     145        wp_die();
     146    }
     147   
     148    public static function asmplsww_set_plugin_version_on_activation() {
     149        update_option('asm_version', ASMPLSWW_VERSION);
     150    }
    45151}
     152
     153// Initialize plugin
     154new Aadvance_Shipping_Plugin();
  • asm-manager/trunk/changelog.txt

    r3303098 r3311966  
    11== Changelog ==
     2= 1.4.0 =
     3* MAJOR UPDATE!  IF YOU ARE UPDATING FROM 1.3 - PLEASE CONTACT US FIRST at 888-546-4932
     4* Embedded admin access
     5* Export/Import functionality added.
     6* Performance improvements
     7
     8= 1.3.2 =
     9* Tax Connector fix
     10
     11= 1.3.1 =
     12* Optional Tax Connector extension for AvaTax, TaxJar, and TaxCloud
     13
    214= 1.3 =
    315* Details page improvements
  • asm-manager/trunk/includes/asmplsww_admin_field.php

    r3303098 r3311966  
    22/**
    33 * @package Asm_Admin_Field
    4  * @version 1.3
     4 * @version 1.4
    55 */
    66
     
    1111        {
    1212            /** Hook callback function to Add Tab in Product option section */
    13             add_filter('woocommerce_product_data_tabs', 'asmplsww_admin_tab_add');
    14             function asmplsww_admin_tab_add($product_data_tabs)
    15             {
    16                 $product_data_tabs['asmplsww-custom-tab'] = array(
    17                     'label' => __('Advanced Shipping Manager', 'asmplsww_text_domain'),
    18                     'target' => 'asmplsww_custom_product_data',
    19                 );
    20                 return $product_data_tabs;
     13            add_filter('woocommerce_product_data_tabs', [$this, 'asmplsww_admin_tab_add']);
     14
     15            /** Hook callback function to Add custom fields information */
     16            add_action('woocommerce_product_data_panels', [$this, 'asmplsww_admin_fields_add']);
     17
     18            add_action('woocommerce_process_product_meta', [$this, 'asmplsww_admin_fields_save']);
     19
     20        }
     21
     22        function asmplsww_admin_tab_add($product_data_tabs)
     23        {
     24            $product_data_tabs['asmplsww-custom-tab'] = array(
     25                'label' => __('Advanced Shipping Manager', 'asmplsww'),
     26                'target' => 'asmplsww_custom_product_data',
     27            );
     28            return $product_data_tabs;
     29        }
     30
     31        function asmplsww_admin_fields_add()
     32        {
     33            global $woocommerce, $post;
     34
     35            // id below must match target registered in above add_my_custom_product_data_tab function
     36            echo "<div id=\"asmplsww_custom_product_data\" class=\"panel woocommerce_options_panel\">";
     37            woocommerce_wp_text_input(
     38                array(
     39                    'id' => 'asmplsww_dimensions',
     40                    'label' => __('Dimensions', 'asmplsww'),
     41                    'desc_tip' => 'true',
     42                    'description' => __('Enter the Dimension of package.', 'asmplsww')
     43                )
     44            );
     45
     46            $checked_free_shipping = '';
     47            $asmplsww_free_shipping = get_post_meta($post->ID, 'asmplsww_free_shipping', true);
     48            if ($asmplsww_free_shipping == 1) {
     49                $checked_free_shipping = "checked=checked";
    2150            }
    22 
    23             /** Hook callback function to Add custom fields information */
    24             add_action('woocommerce_product_data_panels', 'asmplsww_admin_fields_add');
    25             function asmplsww_admin_fields_add()
    26             {
    27                 global $woocommerce, $post;
    28 
    29                 // id below must match target registered in above add_my_custom_product_data_tab function
    30                 echo "<div id=\"asmplsww_custom_product_data\" class=\"panel woocommerce_options_panel\">";
    31                 woocommerce_wp_text_input(
    32                     array(
    33                         'id' => 'asmplsww_dimensions',
    34                         'label' => __('Dimensions', 'as_dimensions'),
    35                         'desc_tip' => 'true',
    36                         'description' => __('Enter the Dimension of package.', 'woocommerce')
    37                     )
    38                 );
    39 
    40                 $checked_free_shipping = '';
    41                 $asmplsww_free_shipping = get_post_meta($post->ID, 'asmplsww_free_shipping', true);
    42                 if ($asmplsww_free_shipping == 1) {
    43                     $checked_free_shipping = "checked=checked";
    44                 }
    45                 echo "<p class=\"form-field asmplsww_free_shipping \"><label>Free Shipping</label>";
    46                 echo "<input type=\"checkbox\" id=\"asmplsww_free_shipping\" name=\"asmplsww_free_shipping\" value=\"1\"  $checked_free_shipping>";
    47 
    48                 woocommerce_wp_text_input(
    49                     array(
    50                         'id' => 'asmplsww_free_shipping_method',
    51                         'label' => __('Free Shipping Method', 'asm_free_shipping_method'),
    52                         'desc_tip' => 'true',
    53                         'description' => __('Enter Free Shipping Method', 'woocommerce')
    54                     )
    55                 );
    56 
    57                 $asmplsww_ship_alone_checked = '';
    58                 $asmplsww_ship_alone = get_post_meta($post->ID, 'asmplsww_ship_alone', true);
    59                 if ($asmplsww_ship_alone == 1) {
    60                     $asmplsww_ship_alone_checked = "checked=checked";
    61                 }
    62                 echo "<p class=\"form-field asmplsww_ship_alone \"><label>Ship Alone</label>";
    63                 echo "<input type=\"checkbox\" id=\"asmplsww_ship_alone\" name=\"asmplsww_ship_alone\" value=\"1\"  $asmplsww_ship_alone_checked>";
    64 
    65                 woocommerce_wp_textarea_input(
    66                     array(
    67                         'id' => 'asmplsww_flat_ship_rates',
    68                         'label' => __('Flat Ship Rates', 'asm_flat_ship_rates'),
    69                         'desc_tip' => 'true',
    70                         'description' => __('Enter Flat Ship Rates', 'woocommerce')
    71                     )
    72                 );
    73 
    74                 woocommerce_wp_text_input(
    75                     array(
    76                         'id' => 'asmplsww_origin_zip',
    77                         'label' => __('Origin Zip', 'asm_origin_zip'),
    78                         'desc_tip' => 'true',
    79                         'description' => __('Enter Origin Zip', 'woocommerce')
    80                     )
    81                 );
    82 
    83                 woocommerce_wp_text_input(
    84                     array(
    85                         'id' => 'asmplsww_addons_number_boxes',
    86                         'label' => __('Number of Boxes', 'asmplsww_addons_number_boxes'),
    87                         'desc_tip' => 'true',
    88                         'description' => __('Enter Number of Boxes', 'woocommerce')
    89                     )
    90                 );
    91 
    92                 woocommerce_wp_text_input(
    93                     array(
    94                         'id' => 'asmplsww_multi_box_weight',
    95                         'label' => __('Multi Box Weights', 'asm_multi_box_weight'),
    96                         'desc_tip' => 'true',
    97                         'description' => __('Enter Multi Box Weights', 'woocommerce')
    98                     )
    99                 );
    100 
    101                 woocommerce_wp_textarea_input(
    102                     array(
    103                         'id' => 'asmplsww_multi_box_dimensions',
    104                         'label' => __('Multi Box Dimensions', 'asm_multi_box_dimensions'),
    105                         'desc_tip' => 'true',
    106                         'description' => __('Enter Multi Box Dimensions', 'woocommerce')
    107                     )
    108                 );
    109 
    110                 woocommerce_wp_text_input(
    111                     array(
    112                         'id' => 'asmplsww_invalid_ship_methods',
    113                         'label' => __('Invalid Ship Methods', 'asm_invalid_ship_methods'),
    114                         'desc_tip' => 'true',
    115                         'description' => __('Enter Invalid Ship Methods', 'woocommerce')
    116                     )
    117                 );
    118 
    119                 woocommerce_wp_text_input(
    120                     array(
    121                         'id' => 'asmplsww_markup',
    122                         'label' => __('Markup', 'asm_markup'),
    123                         'desc_tip' => 'true',
    124                         'description' => __('Enter Markup', 'woocommerce')
    125                     )
    126                 );
    127 
    128                 $asmplsww_global_free_ship_exclusion_checked = '';
    129                 $asmplsww_global_free_ship_exclusion = get_post_meta($post->ID, 'asmplsww_global_free_ship_exclusion', true);
    130                 if ($asmplsww_global_free_ship_exclusion == 1) {
    131                     $asmplsww_global_free_ship_exclusion_checked = "checked=checked";
    132                 }
    133                 echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Global Free Ship Exclusion</label>";
    134                 echo "<input type=\"checkbox\" id=\"asmplsww_global_free_ship_exclusion\" name=\"asmplsww_global_free_ship_exclusion\" value=\"1\"  $asmplsww_global_free_ship_exclusion_checked>";
    135 
    136                 woocommerce_wp_textarea_input(
    137                     array(
    138                         'id' => 'asmplsww_exclude_state',
    139                         'label' => __('Exclude States', 'asm_exclude_state'),
    140                         'desc_tip' => 'true',
    141                         'description' => __('Enter Exclude States', 'woocommerce')
    142                     )
    143                 );
    144 
    145                 woocommerce_wp_textarea_input(
    146                     array(
    147                         'id' => 'asmplsww_exclude_countries',
    148                         'label' => __('Exclude Countries', 'asm_exclude_countries'),
    149                         'desc_tip' => 'true',
    150                         'description' => __('Enter Exclude Countries', 'woocommerce')
    151                     )
    152                 );
    153 
    154                 echo "<h1 style='padding-left:10px;border-bottom: 1px solid #ccc;'>Optional Add-Ons</h1>";
    155 
    156                 woocommerce_wp_text_input(
    157                     array(
    158                         'id' => 'asmplsww_addons_item_points',
    159                         'label' => __('Item Points', 'asm_addons_item_points'),
    160                         'desc_tip' => 'true',
    161                         'description' => __('Enter Item Points', 'woocommerce')
    162                     )
    163                 );
    164 
    165                 woocommerce_wp_text_input(
    166                     array(
    167                         'id' => 'asmplsww_addons_multi_box_points',
    168                         'label' => __('Multi Box Points', 'asmplsww_addons_multi_box_points'),
    169                         'desc_tip' => 'true',
    170                         'description' => __('Enter Item Points', 'woocommerce')
    171                     )
    172                 );
    173 
    174                 woocommerce_wp_text_input(
    175                     array(
    176                         'id' => 'asmplsww_addons_bundled_qty',
    177                         'label' => __('Bundled Quantity', 'asmplsww_addons_bundled_qty'),
    178                         'desc_tip' => 'true',
    179                         'description' => __('Enter Bundled Qty', 'woocommerce')
    180                     )
    181                 );
    182 
    183                 woocommerce_wp_text_input(
    184                     array(
    185                         'id' => 'asmplsww_addons_bundled_weight',
    186                         'label' => __('Bundled Weight', 'asmplsww_addons_bundled_weight'),
    187                         'desc_tip' => 'true',
    188                         'description' => __('Enter Bundled Weight', 'woocommerce')
    189                     )
    190                 );
    191 
    192                 woocommerce_wp_text_input(
    193                     array(
    194                         'id' => 'asmplsww_addons_bundled_dimension',
    195                         'label' => __('Bundled Dimensions', 'asmplsww_addons_bundled_dimension'),
    196                         'desc_tip' => 'true',
    197                         'description' => __('Enter Bundled Dimension', 'woocommerce')
    198                     )
    199                 );
    200 
    201                 woocommerce_wp_text_input(
    202                     array(
    203                         'id' => 'asmplsww_addons_bundled_points',
    204                         'label' => __('Bundled Points', 'asmplsww_addons_bundled_points'),
    205                         'desc_tip' => 'true',
    206                         'description' => __('Enter Bundled Points', 'woocommerce')
    207                     )
    208                 );
    209 
    210                 woocommerce_wp_text_input(
    211                     array(
    212                         'id' => 'asmplsww_addons_process_time',
    213                         'label' => __('Processing Time', 'asmplsww_addons_process'),
    214                         'desc_tip' => 'true',
    215                         'description' => __('Enter Process Time', 'woocommerce')
    216                     )
    217                 );
    218 
    219                 $asmplsww_addons_hazmat_checked = '';
    220                 $asmplsww_addons_hazmat = get_post_meta($post->ID, 'asmplsww_addons_hazmat', true);
    221                 if ($asmplsww_addons_hazmat == 1) {
    222                     $asmplsww_addons_hazmat_checked = "checked=checked";
    223                 }
    224                 echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Hazmat</label>";
    225                 echo "<input type=\"checkbox\" id=\"asmplsww_addons_hazmat\" name=\"asmplsww_addons_hazmat\" value=\"1\"  $asmplsww_addons_hazmat_checked>";
    226 
    227                 woocommerce_wp_textarea_input(
    228                     array(
    229                         'id' => 'asmplsww_addons_options_weight_points',
    230                         'label' => __('Option Weight Points', 'asmplsww_addons_options_weight_points'),
    231                         'desc_tip' => 'true',
    232                         'description' => __('Enter Option Weight Points', 'woocommerce')
    233                     )
    234                 );
    235 
    236 
    237                 echo "</div>";
    238 
    239 
     51            echo "<p class=\"form-field asmplsww_free_shipping \"><label>Free Shipping</label>";
     52            echo "<input type=\"checkbox\" id=\"asmplsww_free_shipping\" name=\"asmplsww_free_shipping\" value=\"1\"  $checked_free_shipping>";
     53
     54            woocommerce_wp_text_input(
     55                array(
     56                    'id' => 'asmplsww_free_shipping_method',
     57                    'label' => __('Free Shipping Method', 'asmplsww'),
     58                    'desc_tip' => 'true',
     59                    'description' => __('Enter Free Shipping Method', 'asmplsww')
     60                )
     61            );
     62
     63            $asmplsww_ship_alone_checked = '';
     64            $asmplsww_ship_alone = get_post_meta($post->ID, 'asmplsww_ship_alone', true);
     65            if ($asmplsww_ship_alone == 1) {
     66                $asmplsww_ship_alone_checked = "checked=checked";
    24067            }
    241 
    242             /** Hook callback function to save custom fields information */
    243             function asmplsww_admin_fields_save($post_id)
    244             {
    245 
    246                 // Save Text Field
    247                 $asmplsww_dimensions = $_POST['asmplsww_dimensions'];
    248                 update_post_meta($post_id, 'asmplsww_dimensions', sanitize_text_field($asmplsww_dimensions));
    249 
    250                 // Save Checkbox
    251                 $asmplsww_free_shipping = isset($_POST['asmplsww_free_shipping']) ? true : false;
    252                 update_post_meta($post_id, 'asmplsww_free_shipping', $asmplsww_free_shipping);
    253 
    254                 // Save Hidden field
    255                 $asmplsww_free_shipping_method = $_POST['asmplsww_free_shipping_method'];
    256                 update_post_meta($post_id, 'asmplsww_free_shipping_method', sanitize_text_field($asmplsww_free_shipping_method));
    257 
    258                 $asmplsww_ship_alone = isset($_POST['asmplsww_ship_alone']) ? true : false;
    259                 update_post_meta($post_id, 'asmplsww_ship_alone', $asmplsww_ship_alone);
    260 
    261                 $asmplsww_flat_ship_rates = $_POST['asmplsww_flat_ship_rates'];
    262                 update_post_meta($post_id, 'asmplsww_flat_ship_rates', sanitize_textarea_field($asmplsww_flat_ship_rates));
    263 
    264                 $asmplsww_origin_zip = $_POST['asmplsww_origin_zip'];
    265                 update_post_meta($post_id, 'asmplsww_origin_zip', sanitize_text_field($asmplsww_origin_zip));
    266 
    267                 $asmplsww_multi_box_weight = $_POST['asmplsww_multi_box_weight'];
    268                 update_post_meta($post_id, 'asmplsww_multi_box_weight', sanitize_text_field($asmplsww_multi_box_weight));
    269 
    270                 $asmplsww_multi_box_dimensions = $_POST['asmplsww_multi_box_dimensions'];
    271                 update_post_meta($post_id, 'asmplsww_multi_box_dimensions', sanitize_text_field($asmplsww_multi_box_dimensions));
    272 
    273                 $asmplsww_invalid_ship_methods = $_POST['asmplsww_invalid_ship_methods'];
    274                 update_post_meta($post_id, 'asmplsww_invalid_ship_methods', sanitize_text_field($asmplsww_invalid_ship_methods));
    275 
    276                 $asmplsww_markup = $_POST['asmplsww_markup'];
    277                 update_post_meta($post_id, 'asmplsww_markup', sanitize_text_field($asmplsww_markup));
    278 
    279                 $asmplsww_global_free_ship_exclusion = isset($_POST['asmplsww_global_free_ship_exclusion']) ? true : false;
    280                 update_post_meta($post_id, 'asmplsww_global_free_ship_exclusion', $asmplsww_global_free_ship_exclusion);
    281 
    282                 $asmplsww_exclude_state = $_POST['asmplsww_exclude_state'];
    283                 update_post_meta($post_id, 'asmplsww_exclude_state', sanitize_textarea_field($asmplsww_exclude_state));
    284 
    285                 $asmplsww_exclude_countries = $_POST['asmplsww_exclude_countries'];
    286                 update_post_meta($post_id, 'asmplsww_exclude_countries', sanitize_textarea_field($asmplsww_exclude_countries));
    287 
    288                 $asmplsww_addons_number_boxes = $_POST['asmplsww_addons_number_boxes'];
    289                 update_post_meta($post_id, 'asmplsww_addons_number_boxes', sanitize_text_field($asmplsww_addons_number_boxes));
    290 
    291                 $asmplsww_addons_item_points = $_POST['asmplsww_addons_item_points'];
    292                 update_post_meta($post_id, 'asmplsww_addons_item_points', sanitize_text_field($asmplsww_addons_item_points));
    293 
    294                 $asmplsww_addons_multi_box_points = $_POST['asmplsww_addons_multi_box_points'];
    295                 update_post_meta($post_id, 'asmplsww_addons_multi_box_points', sanitize_text_field($asmplsww_addons_multi_box_points));
    296 
    297                 $asmplsww_addons_bundled_qty = $_POST['asmplsww_addons_bundled_qty'];
    298                 update_post_meta($post_id, 'asmplsww_addons_bundled_qty', sanitize_text_field($asmplsww_addons_bundled_qty));
    299 
    300                 $asmplsww_addons_bundled_weight = $_POST['asmplsww_addons_bundled_weight'];
    301                 update_post_meta($post_id, 'asmplsww_addons_bundled_weight', sanitize_text_field($asmplsww_addons_bundled_weight));
    302 
    303                 $asmplsww_addons_bundled_dimension = $_POST['asmplsww_addons_bundled_dimension'];
    304                 update_post_meta($post_id, 'asmplsww_addons_bundled_dimension', sanitize_text_field($asmplsww_addons_bundled_dimension));
    305 
    306                 $asmplsww_addons_bundled_points = $_POST['asmplsww_addons_bundled_points'];
    307                 update_post_meta($post_id, 'asmplsww_addons_bundled_points', sanitize_text_field($asmplsww_addons_bundled_points));
    308 
    309                 $asmplsww_addons_process_time = $_POST['asmplsww_addons_process_time'];
    310                 update_post_meta($post_id, 'asmplsww_addons_process_time', sanitize_text_field($asmplsww_addons_process_time));
    311 
    312                 $asmplsww_addons_hazmat = isset($_POST['asmplsww_addons_hazmat']) ? true : false;
    313                 update_post_meta($post_id, 'asmplsww_addons_hazmat', $asmplsww_addons_hazmat);
    314 
    315                 $asmplsww_addons_options_weight_points = $_POST['asmplsww_addons_options_weight_points'];
    316                 update_post_meta($post_id, 'asmplsww_addons_options_weight_points', sanitize_textarea_field($asmplsww_addons_options_weight_points));
    317 
    318 
     68            echo "<p class=\"form-field asmplsww_ship_alone \"><label>Ship Alone</label>";
     69            echo "<input type=\"checkbox\" id=\"asmplsww_ship_alone\" name=\"asmplsww_ship_alone\" value=\"1\"  $asmplsww_ship_alone_checked>";
     70
     71            woocommerce_wp_textarea_input(
     72                array(
     73                    'id' => 'asmplsww_flat_ship_rates',
     74                    'label' => __('Flat Ship Rates', 'asm_flat_ship_rates'),
     75                    'desc_tip' => 'true',
     76                    'description' => __('Enter Flat Ship Rates', 'asmplsww')
     77                )
     78            );
     79
     80            woocommerce_wp_text_input(
     81                array(
     82                    'id' => 'asmplsww_origin_zip',
     83                    'label' => __('Origin Zip', 'asm_origin_zip'),
     84                    'desc_tip' => 'true',
     85                    'description' => __('Enter Origin Zip', 'asmplsww')
     86                )
     87            );
     88
     89            woocommerce_wp_text_input(
     90                array(
     91                    'id' => 'asmplsww_addons_number_boxes',
     92                    'label' => __('Number of Boxes', 'asmplsww_addons_number_boxes'),
     93                    'desc_tip' => 'true',
     94                    'description' => __('Enter Number of Boxes', 'asmplsww')
     95                )
     96            );
     97
     98            woocommerce_wp_text_input(
     99                array(
     100                    'id' => 'asmplsww_multi_box_weight',
     101                    'label' => __('Multi Box Weights', 'asm_multi_box_weight'),
     102                    'desc_tip' => 'true',
     103                    'description' => __('Enter Multi Box Weights', 'asmplsww')
     104                )
     105            );
     106
     107            woocommerce_wp_textarea_input(
     108                array(
     109                    'id' => 'asmplsww_multi_box_dimensions',
     110                    'label' => __('Multi Box Dimensions', 'asmplsww'),
     111                    'desc_tip' => 'true',
     112                    'description' => __('Enter Multi Box Dimensions', 'asmplsww')
     113                )
     114            );
     115
     116            woocommerce_wp_text_input(
     117                array(
     118                    'id' => 'asmplsww_invalid_ship_methods',
     119                    'label' => __('Invalid Ship Methods', 'asmplsww'),
     120                    'desc_tip' => 'true',
     121                    'description' => __('Enter Invalid Ship Methods', 'asmplsww')
     122                )
     123            );
     124
     125            woocommerce_wp_text_input(
     126                array(
     127                    'id' => 'asmplsww_markup',
     128                    'label' => __('Markup', 'asmplsww'),
     129                    'desc_tip' => 'true',
     130                    'description' => __('Enter Markup', 'asmplsww')
     131                )
     132            );
     133
     134            $asmplsww_global_free_ship_exclusion_checked = '';
     135            $asmplsww_global_free_ship_exclusion = get_post_meta($post->ID, 'asmplsww_global_free_ship_exclusion', true);
     136            if ($asmplsww_global_free_ship_exclusion == 1) {
     137                $asmplsww_global_free_ship_exclusion_checked = "checked=checked";
    319138            }
    320 
    321             add_action('woocommerce_process_product_meta', 'asmplsww_admin_fields_save');
    322 
     139            echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Global Free Ship Exclusion</label>";
     140            echo "<input type=\"checkbox\" id=\"asmplsww_global_free_ship_exclusion\" name=\"asmplsww_global_free_ship_exclusion\" value=\"1\"  $asmplsww_global_free_ship_exclusion_checked>";
     141
     142            woocommerce_wp_textarea_input(
     143                array(
     144                    'id' => 'asmplsww_exclude_state',
     145                    'label' => __('Exclude States', 'asmplsww'),
     146                    'desc_tip' => 'true',
     147                    'description' => __('Enter Exclude States', 'asmplsww')
     148                )
     149            );
     150
     151            woocommerce_wp_textarea_input(
     152                array(
     153                    'id' => 'asmplsww_exclude_countries',
     154                    'label' => __('Exclude Countries', 'asmplsww'),
     155                    'desc_tip' => 'true',
     156                    'description' => __('Enter Exclude Countries', 'asmplsww')
     157                )
     158            );
     159
     160            echo "<h1 style='padding-left:10px;border-bottom: 1px solid #ccc;'>Optional Add-Ons</h1>";
     161
     162            woocommerce_wp_text_input(
     163                array(
     164                    'id' => 'asmplsww_addons_item_points',
     165                    'label' => __('Item Points', 'asm_addons_item_points'),
     166                    'desc_tip' => 'true',
     167                    'description' => __('Enter Item Points', 'asmplsww')
     168                )
     169            );
     170
     171            woocommerce_wp_text_input(
     172                array(
     173                    'id' => 'asmplsww_addons_multi_box_points',
     174                    'label' => __('Multi Box Points', 'asmplsww_addons_multi_box_points'),
     175                    'desc_tip' => 'true',
     176                    'description' => __('Enter Item Points', 'asmplsww')
     177                )
     178            );
     179
     180            woocommerce_wp_text_input(
     181                array(
     182                    'id' => 'asmplsww_addons_bundled_qty',
     183                    'label' => __('Bundled Quantity', 'asmplsww_addons_bundled_qty'),
     184                    'desc_tip' => 'true',
     185                    'description' => __('Enter Bundled Qty', 'asmplsww')
     186                )
     187            );
     188
     189            woocommerce_wp_text_input(
     190                array(
     191                    'id' => 'asmplsww_addons_bundled_weight',
     192                    'label' => __('Bundled Weight', 'asmplsww_addons_bundled_weight'),
     193                    'desc_tip' => 'true',
     194                    'description' => __('Enter Bundled Weight', 'asmplsww')
     195                )
     196            );
     197
     198            woocommerce_wp_text_input(
     199                array(
     200                    'id' => 'asmplsww_addons_bundled_dimension',
     201                    'label' => __('Bundled Dimensions', 'asmplsww_addons_bundled_dimension'),
     202                    'desc_tip' => 'true',
     203                    'description' => __('Enter Bundled Dimension', 'asmplsww')
     204                )
     205            );
     206
     207            woocommerce_wp_text_input(
     208                array(
     209                    'id' => 'asmplsww_addons_bundled_points',
     210                    'label' => __('Bundled Points', 'asmplsww_addons_bundled_points'),
     211                    'desc_tip' => 'true',
     212                    'description' => __('Enter Bundled Points', 'asmplsww')
     213                )
     214            );
     215
     216            woocommerce_wp_text_input(
     217                array(
     218                    'id' => 'asmplsww_addons_process_time',
     219                    'label' => __('Processing Time', 'asmplsww'),
     220                    'desc_tip' => 'true',
     221                    'description' => __('Enter Process Time', 'asmplsww')
     222                )
     223            );
     224
     225            $asmplsww_addons_hazmat_checked = '';
     226            $asmplsww_addons_hazmat = get_post_meta($post->ID, 'asmplsww_addons_hazmat', true);
     227            if ($asmplsww_addons_hazmat == 1) {
     228                $asmplsww_addons_hazmat_checked = "checked=checked";
     229            }
     230            echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Hazmat</label>";
     231            echo "<input type=\"checkbox\" id=\"asmplsww_addons_hazmat\" name=\"asmplsww_addons_hazmat\" value=\"1\"  $asmplsww_addons_hazmat_checked>";
     232
     233            woocommerce_wp_textarea_input(
     234                array(
     235                    'id' => 'asmplsww_addons_options_weight_points',
     236                    'label' => __('Option Weight Points', 'asmplsww'),
     237                    'desc_tip' => 'true',
     238                    'description' => __('Enter Option Weight Points', 'asmplsww')
     239                )
     240            );
     241
     242
     243            echo "</div>";
    323244        }
     245
     246
     247        /** Hook callback function to save custom fields information */
     248        function asmplsww_admin_fields_save($post_id)
     249        {
     250
     251            // Save Text Field
     252            $asmplsww_dimensions = $_POST['asmplsww_dimensions'];
     253            update_post_meta($post_id, 'asmplsww_dimensions', sanitize_text_field($asmplsww_dimensions));
     254
     255            // Save Checkbox
     256            $asmplsww_free_shipping = isset($_POST['asmplsww_free_shipping']) ? true : false;
     257            update_post_meta($post_id, 'asmplsww_free_shipping', $asmplsww_free_shipping);
     258
     259            // Save Hidden field
     260            $asmplsww_free_shipping_method = $_POST['asmplsww_free_shipping_method'];
     261            update_post_meta($post_id, 'asmplsww_free_shipping_method', sanitize_text_field($asmplsww_free_shipping_method));
     262
     263            $asmplsww_ship_alone = isset($_POST['asmplsww_ship_alone']) ? true : false;
     264            update_post_meta($post_id, 'asmplsww_ship_alone', $asmplsww_ship_alone);
     265
     266            $asmplsww_flat_ship_rates = $_POST['asmplsww_flat_ship_rates'];
     267            update_post_meta($post_id, 'asmplsww_flat_ship_rates', sanitize_textarea_field($asmplsww_flat_ship_rates));
     268
     269            $asmplsww_origin_zip = $_POST['asmplsww_origin_zip'];
     270            update_post_meta($post_id, 'asmplsww_origin_zip', sanitize_text_field($asmplsww_origin_zip));
     271
     272            $asmplsww_multi_box_weight = $_POST['asmplsww_multi_box_weight'];
     273            update_post_meta($post_id, 'asmplsww_multi_box_weight', sanitize_text_field($asmplsww_multi_box_weight));
     274
     275            $asmplsww_multi_box_dimensions = $_POST['asmplsww_multi_box_dimensions'];
     276            update_post_meta($post_id, 'asmplsww_multi_box_dimensions', sanitize_textarea_field($asmplsww_multi_box_dimensions));
     277
     278            $asmplsww_invalid_ship_methods = $_POST['asmplsww_invalid_ship_methods'];
     279            update_post_meta($post_id, 'asmplsww_invalid_ship_methods', sanitize_text_field($asmplsww_invalid_ship_methods));
     280
     281            $asmplsww_markup = $_POST['asmplsww_markup'];
     282            update_post_meta($post_id, 'asmplsww_markup', sanitize_text_field($asmplsww_markup));
     283
     284            $asmplsww_global_free_ship_exclusion = isset($_POST['asmplsww_global_free_ship_exclusion']) ? true : false;
     285            update_post_meta($post_id, 'asmplsww_global_free_ship_exclusion', $asmplsww_global_free_ship_exclusion);
     286
     287            $asmplsww_exclude_state = $_POST['asmplsww_exclude_state'];
     288            update_post_meta($post_id, 'asmplsww_exclude_state', sanitize_textarea_field($asmplsww_exclude_state));
     289
     290            $asmplsww_exclude_countries = $_POST['asmplsww_exclude_countries'];
     291            update_post_meta($post_id, 'asmplsww_exclude_countries', sanitize_textarea_field($asmplsww_exclude_countries));
     292
     293            $asmplsww_addons_number_boxes = $_POST['asmplsww_addons_number_boxes'];
     294            update_post_meta($post_id, 'asmplsww_addons_number_boxes', sanitize_text_field($asmplsww_addons_number_boxes));
     295
     296            $asmplsww_addons_item_points = $_POST['asmplsww_addons_item_points'];
     297            update_post_meta($post_id, 'asmplsww_addons_item_points', sanitize_text_field($asmplsww_addons_item_points));
     298
     299            $asmplsww_addons_multi_box_points = $_POST['asmplsww_addons_multi_box_points'];
     300            update_post_meta($post_id, 'asmplsww_addons_multi_box_points', sanitize_text_field($asmplsww_addons_multi_box_points));
     301
     302            $asmplsww_addons_bundled_qty = $_POST['asmplsww_addons_bundled_qty'];
     303            update_post_meta($post_id, 'asmplsww_addons_bundled_qty', sanitize_text_field($asmplsww_addons_bundled_qty));
     304
     305            $asmplsww_addons_bundled_weight = $_POST['asmplsww_addons_bundled_weight'];
     306            update_post_meta($post_id, 'asmplsww_addons_bundled_weight', sanitize_text_field($asmplsww_addons_bundled_weight));
     307
     308            $asmplsww_addons_bundled_dimension = $_POST['asmplsww_addons_bundled_dimension'];
     309            update_post_meta($post_id, 'asmplsww_addons_bundled_dimension', sanitize_text_field($asmplsww_addons_bundled_dimension));
     310
     311            $asmplsww_addons_bundled_points = $_POST['asmplsww_addons_bundled_points'];
     312            update_post_meta($post_id, 'asmplsww_addons_bundled_points', sanitize_text_field($asmplsww_addons_bundled_points));
     313
     314            $asmplsww_addons_process_time = $_POST['asmplsww_addons_process_time'];
     315            update_post_meta($post_id, 'asmplsww_addons_process_time', sanitize_text_field($asmplsww_addons_process_time));
     316
     317            $asmplsww_addons_hazmat = isset($_POST['asmplsww_addons_hazmat']) ? true : false;
     318            update_post_meta($post_id, 'asmplsww_addons_hazmat', $asmplsww_addons_hazmat);
     319
     320            $asmplsww_addons_options_weight_points = $_POST['asmplsww_addons_options_weight_points'];
     321            update_post_meta($post_id, 'asmplsww_addons_options_weight_points', sanitize_textarea_field($asmplsww_addons_options_weight_points));
     322
     323
     324        }
     325
     326
    324327    }
    325328
  • asm-manager/trunk/includes/asmplsww_product_field.php

    r3303098 r3311966  
    22/**
    33 * @package ASM product field
    4  * @version 1.3
     4 * @version 1.4
    55 */
    66
     
    1111        {
    1212            add_filter('woocommerce_product_data_tabs', 'add_asm_product_data_tab');
    13             function add_asm_product_data_tab($product_data_tabs)
    14             {
    15                 $product_data_tabs['my-custom-tab'] = array(
    16                     'label' => __('Advanced Shipping Manager', 'my_text_domain'),
    17                     'target' => 'my_custom_product_data',
    18                 );
    19                 return $product_data_tabs;
    20             }
    21 
     13           
    2214            add_action('woocommerce_product_data_panels', 'add_asm_product_data_fields');
    23             function add_asm_product_data_fields()
    24             {
    25                 global $woocommerce, $post;
    26 
    27                 // id below must match target registered in above add_my_custom_product_data_tab function
    28                 echo "<div id=\"my_custom_product_data\" class=\"panel woocommerce_options_panel\">";
    29                 woocommerce_wp_text_input(
    30                     array(
    31                         'id' => '_asm_dimensions',
    32                         'label' => __('Dimensions', 'as_dimensions'),
    33                         'desc_tip' => 'true',
    34                         'description' => __('Enter the Dimension of package.', 'woocommerce')
    35                     )
    36                 );
    37 
    38                 $_asm_free_shipping = get_post_meta($post->ID, '_asm_free_shipping', true);
    39                 if ($_asm_free_shipping == 1) {
    40                     $checked_free_shipping = "checked=checked";
    41                 }
    42                 echo "<p class=\"form-field _asm_free_shipping \"><label>Free Shipping</label>";
    43                 echo "<input type=\"checkbox\" id=\"_asm_free_shipping\" name=\"_asm_free_shipping\" value=\"1\"  $checked_free_shipping>";
    44 
    45                 woocommerce_wp_text_input(
    46                     array(
    47                         'id' => '_asm_free_shipping_method',
    48                         'label' => __('Free Shipping Method', 'asm_free_shipping_method'),
    49                         'desc_tip' => 'true',
    50                         'description' => __('Enter Free Shipping Method', 'woocommerce')
    51                     )
    52                 );
    53 
    54 
    55                 $_asm_ship_alone = get_post_meta($post->ID, '_asm_ship_alone', true);
    56                 if ($_asm_ship_alone == 1) {
    57                     $checked_asm_ship_alone = "checked=checked";
    58                 }
    59                 echo "<p class=\"form-field _asm_ship_alone \"><label>Ship Alone</label>";
    60                 echo "<input type=\"checkbox\" id=\"_asm_ship_alone\" name=\"_asm_ship_alone\" value=\"1\"  $checked_asm_ship_alone>";
    61 
    62                 woocommerce_wp_textarea_input(
    63                     array(
    64                         'id' => '_asm_flat_ship_rates',
    65                         'label' => __('Flat Ship Rates', 'asm_flat_ship_rates'),
    66                         'desc_tip' => 'true',
    67                         'description' => __('Enter Flat Ship Rates', 'woocommerce')
    68                     )
    69                 );
    70 
    71                 woocommerce_wp_text_input(
    72                     array(
    73                         'id' => '_asm_origin_zip',
    74                         'label' => __('Origin Zip', 'asm_origin_zip'),
    75                         'desc_tip' => 'true',
    76                         'description' => __('Enter Origin Zip', 'woocommerce')
    77                     )
    78                 );
    79 
    80                 woocommerce_wp_text_input(
    81                     array(
    82                         'id' => '_asm_addons_number_boxes',
    83                         'label' => __('Number of Boxes', '_asm_addons_number_boxes'),
    84                         'desc_tip' => 'true',
    85                         'description' => __('Enter Number of Boxes', 'woocommerce')
    86                     )
    87                 );
    88 
    89                 woocommerce_wp_text_input(
    90                     array(
    91                         'id' => '_asm_multi_box_weight',
    92                         'label' => __('Multi Box Weights', 'asm_multi_box_weight'),
    93                         'desc_tip' => 'true',
    94                         'description' => __('Enter Multi Box Weights', 'woocommerce')
    95                     )
    96                 );
    97 
    98                 woocommerce_wp_textarea_input(
    99                     array(
    100                         'id' => '_asm_multi_box_dimensions',
    101                         'label' => __('Multi Box Dimensions', 'asm_multi_box_dimensions'),
    102                         'desc_tip' => 'true',
    103                         'description' => __('Enter Multi Box Dimensions', 'woocommerce')
    104                     )
    105                 );
    106 
    107                 woocommerce_wp_text_input(
    108                     array(
    109                         'id' => '_asm_invalid_ship_methods',
    110                         'label' => __('Invalid Ship Methods', 'asm_invalid_ship_methods'),
    111                         'desc_tip' => 'true',
    112                         'description' => __('Enter Invalid Ship Methods', 'woocommerce')
    113                     )
    114                 );
    115 
    116                 woocommerce_wp_text_input(
    117                     array(
    118                         'id' => '_asm_markup',
    119                         'label' => __('Markup', 'asm_markup'),
    120                         'desc_tip' => 'true',
    121                         'description' => __('Enter Markup', 'woocommerce')
    122                     )
    123                 );
    124 
    125                 $_asm_global_free_ship_exclusion = get_post_meta($post->ID, '_asm_global_free_ship_exclusion', true);
    126                 if ($_asm_global_free_ship_exclusion == 1) {
    127                     $checked_asm_global_free_ship_exclusion = "checked=checked";
    128                 }
    129                 echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Global Free Ship Exclusion</label>";
    130                 echo "<input type=\"checkbox\" id=\"_asm_global_free_ship_exclusion\" name=\"_asm_global_free_ship_exclusion\" value=\"1\"  $checked_asm_global_free_ship_exclusion>";
    131 
    132                 woocommerce_wp_textarea_input(
    133                     array(
    134                         'id' => '_asm_exclude_state',
    135                         'label' => __('Exclude States', 'asm_exclude_state'),
    136                         'desc_tip' => 'true',
    137                         'description' => __('Enter Exclude States', 'woocommerce')
    138                     )
    139                 );
    140 
    141                 woocommerce_wp_textarea_input(
    142                     array(
    143                         'id' => '_asm_exclude_countries',
    144                         'label' => __('Exclude Countries', 'asm_exclude_countries'),
    145                         'desc_tip' => 'true',
    146                         'description' => __('Enter Exclude Countries', 'woocommerce')
    147                     )
    148                 );
    149 
    150                 echo "<h1 style='padding-left:10px;border-bottom: 1px solid #ccc;'>Optional Add-Ons</h1>";
    151 
    152                 woocommerce_wp_text_input(
    153                     array(
    154                         'id' => '_asm_addons_item_points',
    155                         'label' => __('Item Points', 'asm_addons_item_points'),
    156                         'desc_tip' => 'true',
    157                         'description' => __('Enter Item Points', 'woocommerce')
    158                     )
    159                 );
    160 
    161                 woocommerce_wp_text_input(
    162                     array(
    163                         'id' => '_asm_addons_multi_box_points',
    164                         'label' => __('Multi Box Points', '_asm_addons_multi_box_points'),
    165                         'desc_tip' => 'true',
    166                         'description' => __('Enter Item Points', 'woocommerce')
    167                     )
    168                 );
    169 
    170                 woocommerce_wp_text_input(
    171                     array(
    172                         'id' => '_asm_addons_bundled_qty',
    173                         'label' => __('Bundled Quantity', '_asm_addons_bundled_qty'),
    174                         'desc_tip' => 'true',
    175                         'description' => __('Enter Bundled Qty', 'woocommerce')
    176                     )
    177                 );
    178 
    179                 woocommerce_wp_text_input(
    180                     array(
    181                         'id' => '_asm_addons_bundled_weight',
    182                         'label' => __('Bundled Weight', '_asm_addons_bundled_weight'),
    183                         'desc_tip' => 'true',
    184                         'description' => __('Enter Bundled Weight', 'woocommerce')
    185                     )
    186                 );
    187 
    188                 woocommerce_wp_text_input(
    189                     array(
    190                         'id' => '_asm_addons_bundled_dimension',
    191                         'label' => __('Bundled Dimensions', '_asm_addons_bundled_dimension'),
    192                         'desc_tip' => 'true',
    193                         'description' => __('Enter Bundled Dimension', 'woocommerce')
    194                     )
    195                 );
    196 
    197                 woocommerce_wp_text_input(
    198                     array(
    199                         'id' => '_asm_addons_bundled_points',
    200                         'label' => __('Bundled Points', '_asm_addons_bundled_points'),
    201                         'desc_tip' => 'true',
    202                         'description' => __('Enter Bundled Points', 'woocommerce')
    203                     )
    204                 );
    205 
    206                 woocommerce_wp_text_input(
    207                     array(
    208                         'id' => '_asm_addons_process_time',
    209                         'label' => __('Processing Time', '_asm_addons_process'),
    210                         'desc_tip' => 'true',
    211                         'description' => __('Enter Process Time', 'woocommerce')
    212                     )
    213                 );
    214 
    215                 $_asm_addons_hazmat = get_post_meta($post->ID, '_asm_addons_hazmat', true);
    216                 if ($_asm_addons_hazmat == 1) {
    217                     $checked_asm_addons_hazmat = "checked=checked";
    218                 }
    219                 echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Hazmat</label>";
    220                 echo "<input type=\"checkbox\" id=\"_asm_addons_hazmat\" name=\"_asm_addons_hazmat\" value=\"1\"  $checked_asm_addons_hazmat>";
    221 
    222                 woocommerce_wp_textarea_input(
    223                     array(
    224                         'id' => '_asm_addons_options_weight_points',
    225                         'label' => __('Option Weight Points', '_asm_addons_options_weight_points'),
    226                         'desc_tip' => 'true',
    227                         'description' => __('Enter Option Weight Points', 'woocommerce')
    228                     )
    229                 );
    230 
    231 
    232                 echo "</div>";
    233             }
    234 
    235             /** Hook callback function to save custom fields information */
    236             function save_asm_product_data_fields($post_id)
    237             {
    238                 // Save Text Field
    239                 $_asm_dimensions = $_POST['_asm_dimensions'];
    240                 update_post_meta($post_id, '_asm_dimensions', sanitize_text_field($_asm_dimensions));
    241 
    242                 // Save Checkbox
    243                 $_asm_free_shipping = isset($_POST['_asm_free_shipping']) ? true : false;
    244                 update_post_meta($post_id, '_asm_free_shipping', $_asm_free_shipping);
    245 
    246                 // Save Hidden field
    247                 $_asm_free_shipping_method = $_POST['_asm_free_shipping_method'];
    248                 update_post_meta($post_id, '_asm_free_shipping_method', sanitize_text_field($_asm_free_shipping_method));
    249 
    250                 $_asm_ship_alone = isset($_POST['_asm_ship_alone']) ? true : false;
    251                 update_post_meta($post_id, '_asm_ship_alone', $_asm_ship_alone);
    252 
    253                 $_asm_flat_ship_rates = $_POST['_asm_flat_ship_rates'];
    254                 update_post_meta($post_id, '_asm_flat_ship_rates', sanitize_textarea_field($_asm_flat_ship_rates));
    255 
    256                 $_asm_origin_zip = $_POST['_asm_origin_zip'];
    257                 update_post_meta($post_id, '_asm_origin_zip', sanitize_text_field($_asm_origin_zip));
    258 
    259                 $_asm_multi_box_weight = $_POST['_asm_multi_box_weight'];
    260                 update_post_meta($post_id, '_asm_multi_box_weight', sanitize_text_field($_asm_multi_box_weight));
    261 
    262                 $_asm_multi_box_dimensions = $_POST['_asm_multi_box_dimensions'];
    263                 update_post_meta($post_id, '_asm_multi_box_dimensions', sanitize_text_field($_asm_multi_box_dimensions));
    264 
    265                 $_asm_invalid_ship_methods = $_POST['_asm_invalid_ship_methods'];
    266                 update_post_meta($post_id, '_asm_invalid_ship_methods', sanitize_text_field($_asm_invalid_ship_methods));
    267 
    268                 $_asm_markup = $_POST['_asm_markup'];
    269                 update_post_meta($post_id, '_asm_markup', sanitize_text_field($_asm_markup));
    270 
    271                 $_asm_global_free_ship_exclusion = isset($_POST['_asm_global_free_ship_exclusion']) ? true : false;
    272                 update_post_meta($post_id, '_asm_global_free_ship_exclusion', $_asm_global_free_ship_exclusion);
    273 
    274                 $_asm_exclude_state = $_POST['_asm_exclude_state'];
    275                 update_post_meta($post_id, '_asm_exclude_state', sanitize_textarea_field($_asm_exclude_state));
    276 
    277                 $_asm_exclude_countries = $_POST['_asm_exclude_countries'];
    278                 update_post_meta($post_id, '_asm_exclude_countries', sanitize_textarea_field($_asm_exclude_countries));
    279 
    280                 $_asm_addons_number_boxes = $_POST['_asm_addons_number_boxes'];
    281                 update_post_meta($post_id, '_asm_addons_number_boxes', sanitize_text_field($_asm_addons_number_boxes));
    282 
    283                 $_asm_addons_item_points = $_POST['_asm_addons_item_points'];
    284                 update_post_meta($post_id, '_asm_addons_item_points', sanitize_text_field($_asm_addons_item_points));
    285 
    286                 $_asm_addons_multi_box_points = $_POST['_asm_addons_multi_box_points'];
    287                 update_post_meta($post_id, '_asm_addons_multi_box_points', sanitize_text_field($_asm_addons_multi_box_points));
    288 
    289                 $_asm_addons_bundled_qty = $_POST['_asm_addons_bundled_qty'];
    290                 update_post_meta($post_id, '_asm_addons_bundled_qty', sanitize_text_field($_asm_addons_bundled_qty));
    291 
    292                 $_asm_addons_bundled_weight = $_POST['_asm_addons_bundled_weight'];
    293                 update_post_meta($post_id, '_asm_addons_bundled_weight', sanitize_text_field($_asm_addons_bundled_weight));
    294 
    295                 $_asm_addons_bundled_dimension = $_POST['_asm_addons_bundled_dimension'];
    296                 update_post_meta($post_id, '_asm_addons_bundled_dimension', sanitize_text_field($_asm_addons_bundled_dimension));
    297 
    298                 $_asm_addons_bundled_points = $_POST['_asm_addons_bundled_points'];
    299                 update_post_meta($post_id, '_asm_addons_bundled_points', sanitize_text_field($_asm_addons_bundled_points));
    300 
    301                 $_asm_addons_process_time = $_POST['_asm_addons_process_time'];
    302                 update_post_meta($post_id, '_asm_addons_process_time', sanitize_text_field($_asm_addons_process_time));
    303 
    304                 $_asm_addons_hazmat = isset($_POST['_asm_addons_hazmat']) ? true : false;
    305                 update_post_meta($post_id, '_asm_addons_hazmat', $_asm_addons_hazmat);
    306 
    307                 $_asm_addons_options_weight_points = $_POST['_asm_addons_options_weight_points'];
    308                 update_post_meta($post_id, '_asm_addons_options_weight_points', sanitize_textarea_field($_asm_addons_options_weight_points));
    309             }
    310 
     15   
    31116            add_action('woocommerce_process_product_meta', 'save_asm_product_data_fields');
    31217        }
     18
     19        function add_asm_product_data_tab($product_data_tabs)
     20        {
     21            $product_data_tabs['my-custom-tab'] = array(
     22                'label' => __('Advanced Shipping Manager', 'asmplsww'),
     23                'target' => 'my_custom_product_data',
     24            );
     25            return $product_data_tabs;
     26        }
     27
     28        function add_asm_product_data_fields()
     29        {
     30            global $woocommerce, $post;
     31
     32            // id below must match target registered in above add_my_custom_product_data_tab function
     33            echo "<div id=\"my_custom_product_data\" class=\"panel woocommerce_options_panel\">";
     34            woocommerce_wp_text_input(
     35                array(
     36                    'id' => '_asm_dimensions',
     37                    'label' => __('Dimensions', 'asmplsww'),
     38                    'desc_tip' => 'true',
     39                    'description' => __('Enter the Dimension of package.', 'asmplsww')
     40                )
     41            );
     42
     43            $_asm_free_shipping = get_post_meta($post->ID, '_asm_free_shipping', true);
     44            if ($_asm_free_shipping == 1) {
     45                $checked_free_shipping = "checked=checked";
     46            }
     47            echo "<p class=\"form-field _asm_free_shipping \"><label>Free Shipping</label>";
     48            echo "<input type=\"checkbox\" id=\"_asm_free_shipping\" name=\"_asm_free_shipping\" value=\"1\"  $checked_free_shipping>";
     49
     50            woocommerce_wp_text_input(
     51                array(
     52                    'id' => '_asm_free_shipping_method',
     53                    'label' => __('Free Shipping Method', 'asmplsww'),
     54                    'desc_tip' => 'true',
     55                    'description' => __('Enter Free Shipping Method', 'asmplsww')
     56                )
     57            );
     58
     59
     60            $_asm_ship_alone = get_post_meta($post->ID, '_asm_ship_alone', true);
     61            if ($_asm_ship_alone == 1) {
     62                $checked_asm_ship_alone = "checked=checked";
     63            }
     64            echo "<p class=\"form-field _asm_ship_alone \"><label>Ship Alone</label>";
     65            echo "<input type=\"checkbox\" id=\"_asm_ship_alone\" name=\"_asm_ship_alone\" value=\"1\"  $checked_asm_ship_alone>";
     66
     67            woocommerce_wp_textarea_input(
     68                array(
     69                    'id' => '_asm_flat_ship_rates',
     70                    'label' => __('Flat Ship Rates', 'asmplsww'),
     71                    'desc_tip' => 'true',
     72                    'description' => __('Enter Flat Ship Rates', 'asmplsww')
     73                )
     74            );
     75
     76            woocommerce_wp_text_input(
     77                array(
     78                    'id' => '_asm_origin_zip',
     79                    'label' => __('Origin Zip', 'asmplsww'),
     80                    'desc_tip' => 'true',
     81                    'description' => __('Enter Origin Zip', 'asmplsww')
     82                )
     83            );
     84
     85            woocommerce_wp_text_input(
     86                array(
     87                    'id' => '_asm_addons_number_boxes',
     88                    'label' => __('Number of Boxes', 'asmplsww'),
     89                    'desc_tip' => 'true',
     90                    'description' => __('Enter Number of Boxes', 'asmplsww')
     91                )
     92            );
     93
     94            woocommerce_wp_text_input(
     95                array(
     96                    'id' => '_asm_multi_box_weight',
     97                    'label' => __('Multi Box Weights', 'asmplsww'),
     98                    'desc_tip' => 'true',
     99                    'description' => __('Enter Multi Box Weights', 'asmplsww')
     100                )
     101            );
     102
     103            woocommerce_wp_textarea_input(
     104                array(
     105                    'id' => '_asm_multi_box_dimensions',
     106                    'label' => __('Multi Box Dimensions', 'asmplsww'),
     107                    'desc_tip' => 'true',
     108                    'description' => __('Enter Multi Box Dimensions', 'asmplsww')
     109                )
     110            );
     111
     112            woocommerce_wp_text_input(
     113                array(
     114                    'id' => '_asm_invalid_ship_methods',
     115                    'label' => __('Invalid Ship Methods', 'asmplsww'),
     116                    'desc_tip' => 'true',
     117                    'description' => __('Enter Invalid Ship Methods', 'asmplsww')
     118                )
     119            );
     120
     121            woocommerce_wp_text_input(
     122                array(
     123                    'id' => '_asm_markup',
     124                    'label' => __('Markup', 'asmplsww'),
     125                    'desc_tip' => 'true',
     126                    'description' => __('Enter Markup', 'asmplsww')
     127                )
     128            );
     129
     130            $_asm_global_free_ship_exclusion = get_post_meta($post->ID, '_asm_global_free_ship_exclusion', true);
     131            if ($_asm_global_free_ship_exclusion == 1) {
     132                $checked_asm_global_free_ship_exclusion = "checked=checked";
     133            }
     134            echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Global Free Ship Exclusion</label>";
     135            echo "<input type=\"checkbox\" id=\"_asm_global_free_ship_exclusion\" name=\"_asm_global_free_ship_exclusion\" value=\"1\"  $checked_asm_global_free_ship_exclusion>";
     136
     137            woocommerce_wp_textarea_input(
     138                array(
     139                    'id' => '_asm_exclude_state',
     140                    'label' => __('Exclude States', 'asmplsww'),
     141                    'desc_tip' => 'true',
     142                    'description' => __('Enter Exclude States', 'asmplsww')
     143                )
     144            );
     145
     146            woocommerce_wp_textarea_input(
     147                array(
     148                    'id' => '_asm_exclude_countries',
     149                    'label' => __('Exclude Countries', 'asmplsww'),
     150                    'desc_tip' => 'true',
     151                    'description' => __('Enter Exclude Countries', 'asmplsww')
     152                )
     153            );
     154
     155            echo "<h1 style='padding-left:10px;border-bottom: 1px solid #ccc;'>Optional Add-Ons</h1>";
     156
     157            woocommerce_wp_text_input(
     158                array(
     159                    'id' => '_asm_addons_item_points',
     160                    'label' => __('Item Points', 'asmplsww'),
     161                    'desc_tip' => 'true',
     162                    'description' => __('Enter Item Points', 'asmplsww')
     163                )
     164            );
     165
     166            woocommerce_wp_text_input(
     167                array(
     168                    'id' => '_asm_addons_multi_box_points',
     169                    'label' => __('Multi Box Points', 'asmplsww'),
     170                    'desc_tip' => 'true',
     171                    'description' => __('Enter Item Points', 'asmplsww')
     172                )
     173            );
     174
     175            woocommerce_wp_text_input(
     176                array(
     177                    'id' => '_asm_addons_bundled_qty',
     178                    'label' => __('Bundled Quantity', 'asmplsww'),
     179                    'desc_tip' => 'true',
     180                    'description' => __('Enter Bundled Qty', 'asmplsww')
     181                )
     182            );
     183
     184            woocommerce_wp_text_input(
     185                array(
     186                    'id' => '_asm_addons_bundled_weight',
     187                    'label' => __('Bundled Weight', 'asmplsww'),
     188                    'desc_tip' => 'true',
     189                    'description' => __('Enter Bundled Weight', 'asmplsww')
     190                )
     191            );
     192
     193            woocommerce_wp_text_input(
     194                array(
     195                    'id' => '_asm_addons_bundled_dimension',
     196                    'label' => __('Bundled Dimensions', 'asmplsww'),
     197                    'desc_tip' => 'true',
     198                    'description' => __('Enter Bundled Dimension', 'asmplsww')
     199                )
     200            );
     201
     202            woocommerce_wp_text_input(
     203                array(
     204                    'id' => '_asm_addons_bundled_points',
     205                    'label' => __('Bundled Points', 'asmplsww'),
     206                    'desc_tip' => 'true',
     207                    'description' => __('Enter Bundled Points', 'asmplsww')
     208                )
     209            );
     210
     211            woocommerce_wp_text_input(
     212                array(
     213                    'id' => '_asm_addons_process_time',
     214                    'label' => __('Processing Time', 'asmplsww'),
     215                    'desc_tip' => 'true',
     216                    'description' => __('Enter Process Time', 'asmplsww')
     217                )
     218            );
     219
     220            $_asm_addons_hazmat = get_post_meta($post->ID, '_asm_addons_hazmat', true);
     221            if ($_asm_addons_hazmat == 1) {
     222                $checked_asm_addons_hazmat = "checked=checked";
     223            }
     224            echo "<p class=\"form-field asm_global_free_ship_exclusion \"><label>Hazmat</label>";
     225            echo "<input type=\"checkbox\" id=\"_asm_addons_hazmat\" name=\"_asm_addons_hazmat\" value=\"1\"  $checked_asm_addons_hazmat>";
     226
     227            woocommerce_wp_textarea_input(
     228                array(
     229                    'id' => '_asm_addons_options_weight_points',
     230                    'label' => __('Option Weight Points', 'asmplsww'),
     231                    'desc_tip' => 'true',
     232                    'description' => __('Enter Option Weight Points', 'asmplsww')
     233                )
     234            );
     235
     236
     237            echo "</div>";
     238        }
     239
     240        function save_asm_product_data_fields($post_id)
     241        {
     242            // Save Text Field
     243            $_asm_dimensions = $_POST['_asm_dimensions'];
     244            update_post_meta($post_id, '_asm_dimensions', sanitize_text_field($_asm_dimensions));
     245
     246            // Save Checkbox
     247            $_asm_free_shipping = isset($_POST['_asm_free_shipping']) ? true : false;
     248            update_post_meta($post_id, '_asm_free_shipping', $_asm_free_shipping);
     249
     250            // Save Hidden field
     251            $_asm_free_shipping_method = $_POST['_asm_free_shipping_method'];
     252            update_post_meta($post_id, '_asm_free_shipping_method', sanitize_text_field($_asm_free_shipping_method));
     253
     254            $_asm_ship_alone = isset($_POST['_asm_ship_alone']) ? true : false;
     255            update_post_meta($post_id, '_asm_ship_alone', $_asm_ship_alone);
     256
     257            $_asm_flat_ship_rates = $_POST['_asm_flat_ship_rates'];
     258            update_post_meta($post_id, '_asm_flat_ship_rates', sanitize_textarea_field($_asm_flat_ship_rates));
     259
     260            $_asm_origin_zip = $_POST['_asm_origin_zip'];
     261            update_post_meta($post_id, '_asm_origin_zip', sanitize_text_field($_asm_origin_zip));
     262
     263            $_asm_multi_box_weight = $_POST['_asm_multi_box_weight'];
     264            update_post_meta($post_id, '_asm_multi_box_weight', sanitize_text_field($_asm_multi_box_weight));
     265
     266            $_asm_multi_box_dimensions = $_POST['_asm_multi_box_dimensions'];
     267            update_post_meta($post_id, '_asm_multi_box_dimensions', sanitize_text_field($_asm_multi_box_dimensions));
     268
     269            $_asm_invalid_ship_methods = $_POST['_asm_invalid_ship_methods'];
     270            update_post_meta($post_id, '_asm_invalid_ship_methods', sanitize_text_field($_asm_invalid_ship_methods));
     271
     272            $_asm_markup = $_POST['_asm_markup'];
     273            update_post_meta($post_id, '_asm_markup', sanitize_text_field($_asm_markup));
     274
     275            $_asm_global_free_ship_exclusion = isset($_POST['_asm_global_free_ship_exclusion']) ? true : false;
     276            update_post_meta($post_id, '_asm_global_free_ship_exclusion', $_asm_global_free_ship_exclusion);
     277
     278            $_asm_exclude_state = $_POST['_asm_exclude_state'];
     279            update_post_meta($post_id, '_asm_exclude_state', sanitize_textarea_field($_asm_exclude_state));
     280
     281            $_asm_exclude_countries = $_POST['_asm_exclude_countries'];
     282            update_post_meta($post_id, '_asm_exclude_countries', sanitize_textarea_field($_asm_exclude_countries));
     283
     284            $_asm_addons_number_boxes = $_POST['_asm_addons_number_boxes'];
     285            update_post_meta($post_id, '_asm_addons_number_boxes', sanitize_text_field($_asm_addons_number_boxes));
     286
     287            $_asm_addons_item_points = $_POST['_asm_addons_item_points'];
     288            update_post_meta($post_id, '_asm_addons_item_points', sanitize_text_field($_asm_addons_item_points));
     289
     290            $_asm_addons_multi_box_points = $_POST['_asm_addons_multi_box_points'];
     291            update_post_meta($post_id, '_asm_addons_multi_box_points', sanitize_text_field($_asm_addons_multi_box_points));
     292
     293            $_asm_addons_bundled_qty = $_POST['_asm_addons_bundled_qty'];
     294            update_post_meta($post_id, '_asm_addons_bundled_qty', sanitize_text_field($_asm_addons_bundled_qty));
     295
     296            $_asm_addons_bundled_weight = $_POST['_asm_addons_bundled_weight'];
     297            update_post_meta($post_id, '_asm_addons_bundled_weight', sanitize_text_field($_asm_addons_bundled_weight));
     298
     299            $_asm_addons_bundled_dimension = $_POST['_asm_addons_bundled_dimension'];
     300            update_post_meta($post_id, '_asm_addons_bundled_dimension', sanitize_text_field($_asm_addons_bundled_dimension));
     301
     302            $_asm_addons_bundled_points = $_POST['_asm_addons_bundled_points'];
     303            update_post_meta($post_id, '_asm_addons_bundled_points', sanitize_text_field($_asm_addons_bundled_points));
     304
     305            $_asm_addons_process_time = $_POST['_asm_addons_process_time'];
     306            update_post_meta($post_id, '_asm_addons_process_time', sanitize_text_field($_asm_addons_process_time));
     307
     308            $_asm_addons_hazmat = isset($_POST['_asm_addons_hazmat']) ? true : false;
     309            update_post_meta($post_id, '_asm_addons_hazmat', $_asm_addons_hazmat);
     310
     311            $_asm_addons_options_weight_points = $_POST['_asm_addons_options_weight_points'];
     312            update_post_meta($post_id, '_asm_addons_options_weight_points', sanitize_textarea_field($_asm_addons_options_weight_points));
     313        }
    313314    }
    314315
  • asm-manager/trunk/includes/asmplsww_query_live.php

    r3303098 r3311966  
    22/**
    33 * @package ASM Shipping Api
    4  * @version 1.3
     4 * @version 1.4
    55 */
    66global $woocommerce;
     
    6464
    6565$domainname = '';
    66 $pieces = parse_url(home_url());
     66$pieces = wp_parse_url(home_url());
    6767$domain = isset($pieces['host']) ? $pieces['host'] : '';
    68 if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
    69     $domainname = strstr($regs['domain'], '.', true);
    70 }
     68$domainname = preg_replace('/[^a-z0-9]/i', '', $domain);
     69
    7170
    7271$xml_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
    7372                    <ShippingQuery>
    7473                    <AccountIdentifier>BD8h3Dhs7qj18shr2p</AccountIdentifier>
    75                     <StoreIndicator>" . $domainname . "</StoreIndicator>
    76             <Domain>" . $domain . "</Domain>
     74                    <StoreIndicator>" .$domainname."</StoreIndicator>
     75                    <Domain>" . $domain . "</Domain>
    7776                    <Total>" . ($woocommerce->cart->cart_contents_total + $coupons_amount) . "</Total>
    7877                    <TotalTaxable>" . $TotalTaxbaleProductPrice . "</TotalTaxable>
     
    8786                        <Country>" . $woocommerce->customer->get_shipping_country() . "</Country>
    8887                    </ShipToAddress>
    89                     <Products>";
     88             <Products>";
    9089
    9190foreach ($items as $item => $values) {
  • asm-manager/trunk/includes/asmplsww_shipping_api.php

    r3303098 r3311966  
    22/**
    33 * @package ASM Shipping Api
    4  * @version 1.3
     4 * @version 1.4
    55 */
    66/*
     
    4444            if (self::isValidXml($data)) {
    4545                self::$output = json_decode(json_encode(simplexml_load_string($data)), true);
    46                 if (self::$output) {
     46                if (self::$output && !empty(self::$output['AvailableMethods']['ShippingMethod'])) {
    4747                    return self::$output['AvailableMethods']['ShippingMethod'];
    4848                } else {
  • asm-manager/trunk/includes/asmplsww_shipping_method.php

    r3303098 r3311966  
    11<?php
     2
    23/**
    34 * @package ASM Shipping Method
    4  * @version 1.3
     5 * @version 1.4
    56 */
    67
    7 function asmplsww_shipping_method_init()
    8 {
    9     if (!class_exists('ASMPLSWW_Shipping_Method')) {
    10         class ASMPLSWW_Shipping_Method extends WC_Shipping_Method
     8
     9if (!class_exists('ASMPLSWW_Shipping_Method')) {
     10    class ASMPLSWW_Shipping_Method extends WC_Shipping_Method
     11    {
     12        public function __construct($instance_id = 0)
    1113        {
    12             public function __construct($instance_id = 0)
    13             {
    14                 $this->id = 'asmplsww'; // Id for your shipping method. Should be uunique.
     14            $this->id = 'asmplsww'; // Id for your shipping method. Should be uunique.
    1515
    16                 // new fields added
    17                 $this->instance_id = absint($instance_id);
    18                 $this->supports = array(
    19                     'shipping-zones',
    20                     'instance-settings',
    21                     'instance-settings-modal',
    22                 );
     16            // new fields added
     17            $this->instance_id = absint($instance_id);
     18            $this->supports = array(
     19                'shipping-zones',
     20                'instance-settings',
     21                'instance-settings-modal',
     22            );
    2323
    24                 $this->method_title = __('Advanced Shipping Manager');  // Title shown in admin
    25                 $this->method_description = __('Description of your shipping method'); // Description shown in admin
     24            $this->method_title = __('Advanced Shipping Manager', 'asmplsww');  // Title shown in admin
     25            $this->method_description = __('Description of your shipping method', 'asmplsww'); // Description shown in admin
    2626
    27                 $this->enabled = "yes"; // This can be added as an setting but for this example its forced enabled
    28                 $this->title = 'Advanced Shipping Manager';// This can be added as an setting but for this example its forced.
     27            $this->enabled = "yes"; // This can be added as an setting but for this example its forced enabled
     28            $this->title = 'Advanced Shipping Manager'; // This can be added as an setting but for this example its forced.
    2929
    30                 $this->init();
     30            $this->init();
     31        }
     32
     33        function init()
     34        {
     35            // Load the settings API
     36            $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
     37            $this->init_settings(); // This is part of the settings API. Loads settings you previously init.
     38
     39            // Save settings in admin if you have any defined
     40            add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'add_asmplsww_shipping_method'));
     41        }
     42
     43        /**
     44         * Form Fields
     45         */
     46        public function init_form_fields()
     47        {
     48            $this->instance_form_fields = array(
     49                'enabled' => array(
     50                    'title' => __('Enable / Disable', 'asmplsww'),
     51                    'type' => 'checkbox',
     52                    'label' => __('Enable This Shipping Service', 'asmplsww'),
     53                    'default' => 'yes',
     54                    'id' => 'asmplsww_enable_disable_shipping',
     55                ),
     56            );
     57        }
     58
     59        public function calculate_shipping($package = array())
     60        {
     61
     62            global $woocommerce;
     63            //live query
     64            include 'asmplsww_query_live.php';
     65
     66            //Shipping API
     67            if (!class_exists('ASMPLSWW_Shipping_Api')) {
     68                include_once 'asmplsww_shipping_api.php';
     69            }
     70            $city    = $woocommerce->customer->get_shipping_city();
     71            $state   = $woocommerce->customer->get_shipping_state();
     72            $zip     = $woocommerce->customer->get_shipping_postcode();
     73            $country = $woocommerce->customer->get_shipping_country();
     74
     75            try {
     76                if (!empty($city) && !empty($state) && !empty($zip) && !empty($country)) {
     77
     78                    if (is_user_logged_in()) {
     79                        $user_id = get_current_user_id();
     80                    } else {
     81                        $user_id = WC()->session->get('guest_id');
     82
     83                        if (!$user_id) {
     84                            $user_id = 'guest_' . uniqid();
     85                            WC()->session->set('guest_id', $user_id);
     86                        }
     87                    }
     88
     89                    $cache_lifetime = 15 * MINUTE_IN_SECONDS;
     90
     91                    $cached_cart_data = get_transient('asm_cart_data_' . $user_id);
     92                    $cached_cart_data_time = get_transient('asm_cart_data_time');
     93                    $current_time = time();
     94                    $time_difference = $current_time - intval($cached_cart_data_time);
     95                    $recalc_flag = WC()->session->get('force_shipping_recalc');
     96
     97                    if ($time_difference > $cache_lifetime || empty($cached_cart_data) || defined('DOING_AJAX') && DOING_AJAX || $recalc_flag) {
     98                        WC()->session->__unset('force_shipping_recalc'); // clear f
     99                        $shippingValues = ASMPLSWW_Shipping_Api::asmplswwGetShippingValue($xml_data);
     100                        set_transient('asm_cart_data_' . $user_id, $shippingValues, $cache_lifetime);
     101                        set_transient('asm_cart_data_time', $current_time, $cache_lifetime);
     102                    } else {
     103                        $shippingValues = $cached_cart_data;
     104                    }
     105                }
     106
     107            } catch (Exception $e) {
     108                $message = $e->getMessage();
     109                $messageType = "error";
     110                wc_add_notice($message, $messageType);
    31111            }
    32112
    33             function init()
    34             {
    35                 // Load the settings API
    36                 $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
    37                 $this->init_settings(); // This is part of the settings API. Loads settings you previously init.
    38 
    39                 // Save settings in admin if you have any defined
    40                 add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'add_asmplsww_shipping_method'));
    41 
    42             }
    43 
    44             /**
    45              * Form Fields
    46              */
    47             public function init_form_fields()
    48             {
    49                 $this->instance_form_fields = array(
    50                     'enabled' => array(
    51                         'title' => __('Enable / Disable', 'woocommerce'),
    52                         'type' => 'checkbox',
    53                         'label' => __('Enable This Shipping Service', 'woocommerce'),
    54                         'default' => 'yes',
    55                         'id' => 'asmplsww_enable_disable_shipping',
    56                     ),
     113            if (isset($shippingValues['Name'], $shippingValues['Rate'])) {
     114                $shipping_single_rate = array(
     115                    'id' => $this->id,
     116                    'label' => $shippingValues['Name'],
     117                    'cost' => $shippingValues['Rate'],
     118                    'taxes' => array($shippingValues['TaxRate']),
     119                    'calc_tax' => 'per_order',
    57120                );
    58             }
    59 
    60             public function calculate_shipping($package = array())
    61             {
    62                 //live query
    63                 include 'asmplsww_query_live.php';
    64 
    65                 //Shipping API
    66                 if (!class_exists('ASMPLSWW_Shipping_Api')) {
    67                     include_once 'asmplsww_shipping_api.php';
    68                 }
    69 
    70                 try {
    71                     $shippingValues = ASMPLSWW_Shipping_Api::asmplswwGetShippingValue($xml_data);
    72                 } catch (Exception $e) {
    73                     $message = $e->getMessage();
    74                     $messageType = "error";
    75                     wc_add_notice($message, $messageType);
    76                 }
    77 
    78                 if (isset($shippingValues['Name'], $shippingValues['Rate'])) {
    79                     $shipping_single_rate = array(
    80                         'id' => $this->id,
    81                         'label' => $shippingValues['Name'],
    82                         'cost' => $shippingValues['Rate'],
    83                     );
    84                     $this->add_rate($shipping_single_rate);
    85                 } else if (is_array($shippingValues) && !empty($shippingValues)) {
    86                     foreach ($shippingValues as $key => $value) {
    87                         if ($shippingValues[$key]['Rate']) {
    88                             $shipping_rate = array(
    89                                 'id' => 'key_' . $key,
    90                                 'label' => $shippingValues[$key]['Name'],
    91                                 'cost' => $shippingValues[$key]['Rate'],
    92                             );
    93                             $this->add_rate($shipping_rate);
    94                         }
     121                $this->add_rate($shipping_single_rate);
     122            } else if (is_array($shippingValues) && !empty($shippingValues)) {
     123                foreach ($shippingValues as $key => $value) {
     124                    if ($shippingValues[$key]['Rate']) {
     125                        $shipping_rate = array(
     126                            'id' => 'key_' . $key,
     127                            'label' => $shippingValues[$key]['Name'],
     128                            'cost' => $shippingValues[$key]['Rate'],
     129                            'taxes' => array($shippingValues[$key]['TaxRate']),
     130                            'calc_tax' => 'per_order',
     131                        );
     132                        $this->add_rate($shipping_rate);
    95133                    }
    96134                }
  • asm-manager/trunk/readme.txt

    r3303098 r3311966  
    33Donate link:        https://advancedshippingmanager.com
    44Requires at least:  6.0
    5 Tested up to:       6.8
    6 Stable tag:         1.3
    7 Requires PHP:       5.2.4
     5Tested up to:       6.8.1
     6Stable tag:         1.4
     7Requires PHP:       7.0
    88License:        GPLv2 or later
    99License URI:        https://www.gnu.org/licenses/gpl-2.0.html
    10 Tags:           Advanced Shipping Manager, Shipping Manager, WooCommerce Shipping, Advanced Shipping, WooCommerce Shipping Manager
     10Tags:           Shipping Rates, Advanced Shipping Rates, Advanced Shipping, WooCommerce Shipping, WooCommerce Shipping Rates
    1111
    1212Advanced Shipping Manager delivers full control over ALL of your shipping rules and methods, no matter how complicated your challenge may be!
     
    7373
    7474== Changelog ==
     75= 1.4.0 =
     76* MAJOR UPDATE!  IF YOU ARE UPDATING FROM 1.3 - PLEASE CONTACT US FIRST at 888-546-4932
     77* Embedded admin access
     78* Export/Import functionality added.
     79* Performance improvements
     80
     81= 1.3.2 =
     82* Tax Connector fix
     83
     84= 1.3.1 =
     85* Optional Tax Connector extension for AvaTax, TaxJar, and TaxCloud
     86
    7587= 1.3 =
    7688* Details page improvements
Note: See TracChangeset for help on using the changeset viewer.