Plugin Directory

Changeset 2848152


Ignore:
Timestamp:
01/13/2023 08:09:02 PM (3 years ago)
Author:
advshipmgr
Message:

Update to newest version

Location:
asm-manager
Files:
9 added
7 edited

Legend:

Unmodified
Added
Removed
  • asm-manager/trunk/asmplsww.php

    r2663838 r2848152  
    11<?php
    2 
    32/*
    43  Plugin Name: Advanced Shipping Manager
     
    76  Author: ASM
    87  Developer: ASM
    9   Version: 1.2.3
    10   WC requires at least: 3.7.1
    11   WC tested up to: 6.1.1
     8  Version: 1.2.4
     9  WC requires at least: 7.0.0
     10  WC tested up to: 7.3.0
    1211  Author URI: https://www.advancedshippingmanager.com
    1312 */
     
    1615    exit; // Exit if accessed directly
    1716}
     17
    1818if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
    19 
    2019
    2120    if (!class_exists('ASMPLSWW_Admin')) {
     
    2322    }
    2423
    25     //Asm Shipping Me
     24    // Asm Shipping Method Loading
    2625    if (!class_exists('ASMPLSWW_Shipping_Method')) {
    2726        include_once 'includes/asmplsww_shipping_method.php';
    2827    }
    29    
    30     add_action('woocommerce_shipping_init', 'asmplsww_shipping_method_init');
    3128
    32     function asmplsww_shipping_method_add($methods)
    33     {
    34         $methods['asmplsww'] = 'ASMPLSWW_Shipping_Method';
    35         return $methods;
    36     }
     29    add_action('woocommerce_shipping_init', 'asmplsww_shipping_method_init');
    3730
    38     add_filter('woocommerce_shipping_methods', 'asmplsww_shipping_method_add');
     31    function asmplsww_shipping_method_add($methods)
     32    {
     33        $methods['asmplsww'] = 'ASMPLSWW_Shipping_Method';
     34        return $methods;
     35    }
    3936
     37    add_filter('woocommerce_shipping_methods', 'asmplsww_shipping_method_add');
    4038}
  • asm-manager/trunk/includes/asmplsww_admin_field.php

    r2663838 r2848152  
    22/**
    33 * @package Asm_Admin_Field
    4  * @version 1.2.3
     4 * @version 1.2.4
    55 */
    6 /*
    7 
    8 */
    96
    107if (!class_exists('ASMPLSWW_Admin')) {
    118    class ASMPLSWW_Admin
    129    {
    13 
    1410        public function __construct()
    1511        {
    16 
    1712            /** Hook callback function to Add Tab in Product option section */
    1813            add_filter('woocommerce_product_data_tabs', 'asmplsww_admin_tab_add');
     
    4338                );
    4439
     40                $checked_free_shipping = '';
    4541                $asmplsww_free_shipping = get_post_meta($post->ID, 'asmplsww_free_shipping', true);
    4642                if ($asmplsww_free_shipping == 1) {
     
    5955                );
    6056
    61 
     57                $asmplsww_ship_alone_checked = '';
    6258                $asmplsww_ship_alone = get_post_meta($post->ID, 'asmplsww_ship_alone', true);
    6359                if ($asmplsww_ship_alone == 1) {
     
    130126                );
    131127
     128                $asmplsww_global_free_ship_exclusion_checked = '';
    132129                $asmplsww_global_free_ship_exclusion = get_post_meta($post->ID, 'asmplsww_global_free_ship_exclusion', true);
    133130                if ($asmplsww_global_free_ship_exclusion == 1) {
     
    220217                );
    221218
     219                $asmplsww_addons_hazmat_checked = '';
    222220                $asmplsww_addons_hazmat = get_post_meta($post->ID, 'asmplsww_addons_hazmat', true);
    223221                if ($asmplsww_addons_hazmat == 1) {
  • asm-manager/trunk/includes/asmplsww_product_field.php

    r2663838 r2848152  
    22/**
    33 * @package ASM product field
    4  * @version 1.2.3
     4 * @version 1.2.4
    55 */
    6 /*
    7 
    8 */
     6
    97if (!class_exists('ASMPLSWW_Shipping_Field')) {
    108    class ASMPLSWW_Admin_Field
    119    {
    12 
    1310        public function __construct()
    1411        {
    15 
    1612            add_filter('woocommerce_product_data_tabs', 'add_asm_product_data_tab');
    1713            function add_asm_product_data_tab($product_data_tabs)
     
    2420            }
    2521
    26 
    2722            add_action('woocommerce_product_data_panels', 'add_asm_product_data_fields');
    2823            function add_asm_product_data_fields()
     
    236231
    237232                echo "</div>";
    238 
    239 
    240233            }
    241 
    242234
    243235            /** Hook callback function to save custom fields information */
    244236            function save_asm_product_data_fields($post_id)
    245237            {
    246 
    247238                // Save Text Field
    248239                $_asm_dimensions = $_POST['_asm_dimensions'];
     
    293284                update_post_meta($post_id, '_asm_addons_item_points', sanitize_text_field($_asm_addons_item_points));
    294285
    295 
    296286                $_asm_addons_multi_box_points = $_POST['_asm_addons_multi_box_points'];
    297287                update_post_meta($post_id, '_asm_addons_multi_box_points', sanitize_text_field($_asm_addons_multi_box_points));
     
    317307                $_asm_addons_options_weight_points = $_POST['_asm_addons_options_weight_points'];
    318308                update_post_meta($post_id, '_asm_addons_options_weight_points', sanitize_textarea_field($_asm_addons_options_weight_points));
    319 
    320 
    321309            }
    322310
    323311            add_action('woocommerce_process_product_meta', 'save_asm_product_data_fields');
    324 
    325 
    326312        }
    327313    }
  • asm-manager/trunk/includes/asmplsww_query_live.php

    r2663838 r2848152  
    22/**
    33 * @package ASM Shipping Api
    4  * @version 1.2.3
     4 * @version 1.2.4
    55 */
    6 
    7 /*
    8 */
    9 
    106global $woocommerce;
    117
    128$items = $woocommerce->cart->get_cart();
    13 
    149
    1510//Box Weight
     
    1914
    2015foreach ($items as $item => $values) {
    21 
    2216    //Product is varibale or simple so fetch value as per
    2317    if ($values['variation_id']) {
     
    4337        $NonTaxableProductPrice += ($_product->get_price() * $values['quantity']);
    4438    }
    45 
    4639// check taxable value and set amount
    47 
    48 
    4940}
    5041
    5142//Get Coupon Value
    52 if ($woocommerce->cart->get_applied_coupons()['0'] != "") {
     43$coupons_amount = 0;
     44if (isset($woocommerce->cart->get_applied_coupons()['0']) && $woocommerce->cart->get_applied_coupons()['0'] != "") {
    5345    $coupons_obj = new WC_Coupon($woocommerce->cart->get_applied_coupons()['0']);
    5446    $coupons_amount = $woocommerce->cart->get_subtotal() * $coupons_obj->get_amount() / 100;
     
    5749//Get Coupon Value
    5850if (wc_tax_enabled() == true) {
    59     $TotalTaxable = (($woocommerce->cart->get_subtotal() + $woocommerce->cart->tax_total) - $coupons_amount);
     51    $TotalTaxable = (($woocommerce->cart->get_subtotal()) - $coupons_amount);
    6052}
    6153
    6254//Get Taxable Value
    6355if ($TaxableProductPrice != "") {
    64     $TotalTaxbaleProductPrice = ($TaxableProductPrice + $woocommerce->cart->tax_total);
     56    $TotalTaxbaleProductPrice = $TaxableProductPrice;
    6557}
    6658
     59$domainname = '';
    6760$pieces = parse_url(home_url());
    6861$domain = isset($pieces['host']) ? $pieces['host'] : '';
     
    7669                    <AccountIdentifier>BD8h3Dhs7qj18shr2p</AccountIdentifier>
    7770                    <StoreIndicator>" . $domainname . "</StoreIndicator>
    78                     <Total>" . ($woocommerce->cart->cart_contents_total + $woocommerce->cart->tax_total) . "</Total>
     71                    <Total>" . $woocommerce->cart->cart_contents_total . "</Total>
    7972                    <TotalTaxable>" . $TotalTaxbaleProductPrice . "</TotalTaxable>
    8073                    <TotalNonTaxable>" . $NonTaxableProductPrice . "</TotalNonTaxable>
     
    9184
    9285foreach ($items as $item => $values) {
    93 
    9486    //Product is varibale or simple so fetch value as per
    95     if ($values['variation_id'] != "") {
     87    if (isset($values['variation_id']) && $values['variation_id'] > 0) {
    9688        $_product = wc_get_product($values['variation_id']);
    9789        $getcmeta = get_post_meta($values['product_id']);
     
    10496    }
    10597
    106     $color = $values['variation']['attribute_pa_color'];
    107     $size = $values['variation']['attribute_pa_size'];
     98    $color = isset($values['variation'], $values['variation']['attribute_pa_color']) ? $values['variation']['attribute_pa_color'] : '';
     99    $size = isset($values['variation'], $values['variation']['attribute_pa_size']) ? $values['variation']['attribute_pa_size'] : '';
    108100
    109101    if ($color != "") {
     
    126118                                <Taxable>" . ($_product->get_tax_status() == 'taxable' ? 'Y' : 'N') . "</Taxable>
    127119                                <GiftCertDownloadable>N</GiftCertDownloadable>
    128                                 <Dimensions>" . $getcmeta['asmplsww_dimensions'][0] . "</Dimensions>
    129                                 <FreeShip>" . ($getcmeta['asmplsww_free_shipping']['0'] == 1 ? 'Y' : 'N') . "</FreeShip>
    130                                 <FreeShipMethods>" . $getcmeta['asmplsww_free_shipping_method'][0] . "</FreeShipMethods>
    131                                 <ShipAlone>" . ($getcmeta['asmplsww_ship_alone']['0'] == 1 ? 'Y' : 'N') . "</ShipAlone>
    132                                 <FlatShipRates><![CDATA[" . $getcmeta['asmplsww_flat_ship_rates'][0] . "]]></FlatShipRates>
    133                                 <OriginZip>" . $getcmeta['asmplsww_origin_zip'][0] . "</OriginZip>
    134                                 <MultipleBox>" . $getcmeta['asmplsww_addons_number_boxes'][0] . "</MultipleBox>
    135                                 <MultipleBoxWeights>" . $getcmeta['asmplsww_multi_box_weight'][0] . "</MultipleBoxWeights>
    136                                 <MultipleBoxDimensions><![CDATA[" . $getcmeta['asmplsww_multi_box_dimensions'][0] . "]]></MultipleBoxDimensions>
    137                                 <MultipleBoxPoints>" . $getcmeta['asmplsww_addons_multi_box_points'][0] . "</MultipleBoxPoints>
    138                                 <InvalidMethods>" . $getcmeta['asmplsww_invalid_ship_methods'][0] . "</InvalidMethods>
    139                                 <Markup>" . $getcmeta['asmplsww_markup'][0] . "</Markup>
    140                                 <ItemPoints>" . $getcmeta['asmplsww_addons_item_points'][0] . "</ItemPoints>
    141                                 <BundledQty>" . $getcmeta['asmplsww_addons_bundled_qty'][0] . "</BundledQty>     
    142                                 <BundledWeight>" . $getcmeta['asmplsww_addons_bundled_weight'][0] . "</BundledWeight>
    143                                 <BundledDimensions>" . $getcmeta['asmplsww_addons_bundled_dimension'][0] . "</BundledDimensions>
    144                                 <BundledPoints>" . $getcmeta['asmplsww_addons_bundled_points'][0] . "</BundledPoints>
    145                                 <ExcludeFromFreeShip>" . ($getcmeta['asmplsww_global_free_ship_exclusion']['0'] == 1 ? 'Y' : 'N') . "</ExcludeFromFreeShip>
    146                                 <ProcessTime>" . $getcmeta['asmplsww_addons_process_time']['0'] . "</ProcessTime>
    147                                 <InvalidStates>" . $getcmeta['asmplsww_exclude_state']['0'] . "</InvalidStates>
    148                                 <InvalidCountries>" . $getcmeta['asmplsww_exclude_countries']['0'] . "</InvalidCountries>
    149                                 <HazMat>" . ($getcmeta['asmplsww_addons_hazmat']['0'] == 1 ? 'Y' : 'N') . "</HazMat>
    150                                 <OptionsWeightPoints>" . $getcmeta['asmplsww_addons_options_weight_points']['0'] . "</OptionsWeightPoints>                             
     120                                <Dimensions>" . asmCap($getcmeta, 'asmplsww_dimensions') . "</Dimensions>
     121                                <FreeShip>" . (asmCap($getcmeta, 'asmplsww_free_shipping') == 1 ? 'Y' : 'N') . "</FreeShip>
     122                                <FreeShipMethods>" . asmCap($getcmeta, 'asmplsww_free_shipping_method') . "</FreeShipMethods>
     123                                <ShipAlone>" . (asmCap($getcmeta, 'asmplsww_ship_alone') == 1 ? 'Y' : 'N') . "</ShipAlone>
     124                                <FlatShipRates><![CDATA[" . asmCap($getcmeta, 'asmplsww_flat_ship_rates') . "]]></FlatShipRates>
     125                                <OriginZip>" . asmCap($getcmeta, 'asmplsww_origin_zip') . "</OriginZip>
     126                                <MultipleBox>" . asmCap($getcmeta, 'asmplsww_addons_number_boxes') . "</MultipleBox>
     127                                <MultipleBoxWeights>" . asmCap($getcmeta, 'asmplsww_multi_box_weight') . "</MultipleBoxWeights>
     128                                <MultipleBoxDimensions><![CDATA[" . asmCap($getcmeta, 'asmplsww_multi_box_dimensions') . "]]></MultipleBoxDimensions>
     129                                <MultipleBoxPoints>" . asmCap($getcmeta, 'asmplsww_addons_multi_box_points') . "</MultipleBoxPoints>
     130                                <InvalidMethods>" . asmCap($getcmeta, 'asmplsww_invalid_ship_methods') . "</InvalidMethods>
     131                                <Markup>" . asmCap($getcmeta, 'asmplsww_markup') . "</Markup>
     132                                <ItemPoints>" . asmCap($getcmeta, 'asmplsww_addons_item_points') . "</ItemPoints>
     133                                <BundledQty>" . asmCap($getcmeta, 'asmplsww_addons_bundled_qty') . "</BundledQty>     
     134                                <BundledWeight>" . asmCap($getcmeta, 'asmplsww_addons_bundled_weight') . "</BundledWeight>
     135                                <BundledDimensions>" . asmCap($getcmeta, 'asmplsww_addons_bundled_dimension') . "</BundledDimensions>
     136                                <BundledPoints>" . asmCap($getcmeta, 'asmplsww_addons_bundled_points') . "</BundledPoints>
     137                                <ExcludeFromFreeShip>" . (asmCap($getcmeta, 'asmplsww_global_free_ship_exclusion') == 1 ? 'Y' : 'N') . "</ExcludeFromFreeShip>
     138                                <ProcessTime>" . asmCap($getcmeta, 'asmplsww_addons_process_time') . "</ProcessTime>
     139                                <InvalidStates>" . asmCap($getcmeta, 'asmplsww_exclude_state') . "</InvalidStates>
     140                                <InvalidCountries>" . asmCap($getcmeta, 'asmplsww_exclude_countries') . "</InvalidCountries>
     141                                <HazMat>" . (asmCap($getcmeta, 'asmplsww_addons_hazmat') == 1 ? 'Y' : 'N') . "</HazMat>
     142                                <OptionsWeightPoints>" . asmCap($getcmeta, 'asmplsww_addons_options_weight_points') . "</OptionsWeightPoints>                             
    151143                            </Attributes>
    152144                          </Product>";
    153145}
    154146
    155 
    156147$xml_data .= "</Products>
    157                 <CouponCode>" . $woocommerce->cart->get_applied_coupons()['0'] . "</CouponCode>
     148                <CouponCode>" . (isset($woocommerce->cart->get_applied_coupons()['0']) ? $woocommerce->cart->get_applied_coupons()['0'] : '') . "</CouponCode>
    158149                <CouponValue>" . $coupons_amount . "</CouponValue>
    159150                </ShippingQuery>";
     151
     152function asmCap($getcmeta, $index)
     153{
     154    return isset($getcmeta[$index], $getcmeta[$index]['0']) ? $getcmeta[$index]['0'] : '';
     155}
  • asm-manager/trunk/includes/asmplsww_shipping_api.php

    r2663838 r2848152  
    22/**
    33 * @package ASM Shipping Api
    4  * @version 1.2.3
     4 * @version 1.2.4
    55 */
    66/*
     
    1414//shipping method on
    1515if (!class_exists('ASMPLSWW_Shipping_Api')) {
    16     Class ASMPLSWW_Shipping_Api
     16    class ASMPLSWW_Shipping_Api
    1717    {
    18 
    1918        private static $ch;
    2019        private static $output;
    2120        private static $url = 'https://www.advancedshippingmanager.com/clients/web_services/asm_web_service.php';
    2221
     22        public static function isValidXml($content)
     23        {
     24            $content = trim($content);
     25            if (empty($content)) {
     26                return false;
     27            }
     28
     29            if (stripos($content, '<!DOCTYPE html>') !== false) {
     30                return false;
     31            }
     32
     33            libxml_use_internal_errors(true);
     34            simplexml_load_string($content);
     35            $errors = libxml_get_errors();
     36            libxml_clear_errors();
     37
     38            return empty($errors);
     39        }
     40
    2341        public static function asmplswwGetShippingValue($xml_data)
    2442        {
    2543            $data = wp_remote_retrieve_body(wp_remote_post(self::$url, array('body' => $xml_data)));
    26             self::$output = json_decode(json_encode(simplexml_load_string($data)), true);
    27             if (self::$output) {
    28                 return self::$output['AvailableMethods']['ShippingMethod'];
    29             } else {
    30                 return;
     44            if (self::isValidXml($data)) {
     45                self::$output = json_decode(json_encode(simplexml_load_string($data)), true);
     46                if (self::$output) {
     47                    return self::$output['AvailableMethods']['ShippingMethod'];
     48                } else {
     49                    return;
     50                }
    3151            }
    3252        }
  • asm-manager/trunk/includes/asmplsww_shipping_method.php

    r2663838 r2848152  
    22/**
    33 * @package ASM Shipping Method
    4  * @version 1.2.3
     4 * @version 1.2.4
    55 */
    6 /*
    7 */
    8 
    96
    107function asmplsww_shipping_method_init()
     
    1310        class ASMPLSWW_Shipping_Method extends WC_Shipping_Method
    1411        {
    15 
    1612            public function __construct($instance_id = 0)
    1713            {
    18 
    19 
    2014                $this->id = 'asmplsww'; // Id for your shipping method. Should be uunique.
    2115
    2216                // new fields added
    2317                $this->instance_id = absint($instance_id);
    24                 $this->supports    = array(
     18                $this->supports = array(
    2519                    'shipping-zones',
    2620                    'instance-settings',
     
    3933            function init()
    4034            {
    41 
    4235                // Load the settings API
    4336                $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
     
    5649                $this->instance_form_fields = array(
    5750                    'enabled' => array(
    58                         'title'   => __('Enable / Disable', 'woocommerce'),
    59                         'type'    => 'checkbox',
    60                         'label'   => __('Enable This Shipping Service', 'woocommerce'),
     51                        'title' => __('Enable / Disable', 'woocommerce'),
     52                        'type' => 'checkbox',
     53                        'label' => __('Enable This Shipping Service', 'woocommerce'),
    6154                        'default' => 'yes',
    62                         'id'      => 'asmplsww_enable_disable_shipping',
     55                        'id' => 'asmplsww_enable_disable_shipping',
    6356                    ),
    6457                );
     
    6760            public function calculate_shipping($package = array())
    6861            {
    69                
    7062                //live query
    7163                include 'asmplsww_query_live.php';
    72 
    7364
    7465                //Shipping API
     
    7667                    include_once 'asmplsww_shipping_api.php';
    7768                }
    78                
     69
    7970                try {
    8071                    $shippingValues = ASMPLSWW_Shipping_Api::asmplswwGetShippingValue($xml_data);
     
    8475                    wc_add_notice($message, $messageType);
    8576                }
    86                
    87 //              echo '<pre>';
    88 //              print_r($shippingValues);
    89 //              echo '</pre>'; die;
    90                 if (isset($shippingValues['Name'],$shippingValues['Rate'])) {
    91                     $shipping_single_rate = array(
    92                         'id'    => $this->id,
    93                         'label' => $shippingValues['Name'],
    94                         'cost'  => $shippingValues['Rate'],
    95                     );
    96                     $this->add_rate($shipping_single_rate);
    97                 } else if (!empty($shippingValues)) {
    98                     foreach ($shippingValues as $key => $value) {
    99                         if ($shippingValues[$key]['Rate']) {
    100                             $shipping_rate = array(
    101                                 'id'    => 'key_' . $key,
    102                                 'label' => $shippingValues[$key]['Name'],
    103                                 'cost'  => $shippingValues[$key]['Rate'],
    104                             );
    105                             $this->add_rate($shipping_rate);
    106                         }
    107                     }
    108                 }
    10977
    110 //                 if (!empty($shippingValues)) {
    111 //                     foreach ($shippingValues as $key => $value) {
    112 //                         $shipping_rate = array(
    113 //                             'id' => 'key_' . $key,
    114 //                             'label' => $shippingValues[$key]['Name'],
    115 //                             'cost' => $shippingValues[$key]['Rate']
    116 //                         );
    117 //                         $this->add_rate($shipping_rate);
    118 //                     }
    119 //                 }
    120 
     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                        }
     95                    }
     96                }
    12197            }
    122 
    12398        }
    12499    }
    125 
    126100}
  • asm-manager/trunk/readme.txt

    r2663838 r2848152  
    44Donate link:  https://wordpress.org
    55Requires PHP: 5.2.4
    6 Requires at least: 4.0
    7 Tested up to: 5.9
    8 Stable tag: 5.9
     6Requires at least: 6.0
     7Tested up to: 6.1
     8Stable tag: 1.2.4
    99
    1010== Description ==
     
    6868
    6969== Changelog ==
     70= 1.2.4 =
     71* PHP v8 supported
     72* Bug fixes
     73
    7074= 1.2.3 =
    7175* Bug fixes
Note: See TracChangeset for help on using the changeset viewer.