Changeset 2848152
- Timestamp:
- 01/13/2023 08:09:02 PM (3 years ago)
- Location:
- asm-manager
- Files:
-
- 9 added
- 7 edited
-
tags/1.2.3 (added)
-
tags/1.2.3/asmplsww.php (added)
-
tags/1.2.3/includes (added)
-
tags/1.2.3/includes/asmplsww_admin_field.php (added)
-
tags/1.2.3/includes/asmplsww_product_field.php (added)
-
tags/1.2.3/includes/asmplsww_query_live.php (added)
-
tags/1.2.3/includes/asmplsww_shipping_api.php (added)
-
tags/1.2.3/includes/asmplsww_shipping_method.php (added)
-
tags/1.2.3/readme.txt (added)
-
trunk/asmplsww.php (modified) (4 diffs)
-
trunk/includes/asmplsww_admin_field.php (modified) (5 diffs)
-
trunk/includes/asmplsww_product_field.php (modified) (5 diffs)
-
trunk/includes/asmplsww_query_live.php (modified) (8 diffs)
-
trunk/includes/asmplsww_shipping_api.php (modified) (2 diffs)
-
trunk/includes/asmplsww_shipping_method.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
asm-manager/trunk/asmplsww.php
r2663838 r2848152 1 1 <?php 2 3 2 /* 4 3 Plugin Name: Advanced Shipping Manager … … 7 6 Author: ASM 8 7 Developer: ASM 9 Version: 1.2. 310 WC requires at least: 3.7.111 WC tested up to: 6.1.18 Version: 1.2.4 9 WC requires at least: 7.0.0 10 WC tested up to: 7.3.0 12 11 Author URI: https://www.advancedshippingmanager.com 13 12 */ … … 16 15 exit; // Exit if accessed directly 17 16 } 17 18 18 if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { 19 20 19 21 20 if (!class_exists('ASMPLSWW_Admin')) { … … 23 22 } 24 23 25 // Asm Shipping Me24 // Asm Shipping Method Loading 26 25 if (!class_exists('ASMPLSWW_Shipping_Method')) { 27 26 include_once 'includes/asmplsww_shipping_method.php'; 28 27 } 29 30 add_action('woocommerce_shipping_init', 'asmplsww_shipping_method_init');31 28 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'); 37 30 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 } 39 36 37 add_filter('woocommerce_shipping_methods', 'asmplsww_shipping_method_add'); 40 38 } -
asm-manager/trunk/includes/asmplsww_admin_field.php
r2663838 r2848152 2 2 /** 3 3 * @package Asm_Admin_Field 4 * @version 1.2. 34 * @version 1.2.4 5 5 */ 6 /*7 8 */9 6 10 7 if (!class_exists('ASMPLSWW_Admin')) { 11 8 class ASMPLSWW_Admin 12 9 { 13 14 10 public function __construct() 15 11 { 16 17 12 /** Hook callback function to Add Tab in Product option section */ 18 13 add_filter('woocommerce_product_data_tabs', 'asmplsww_admin_tab_add'); … … 43 38 ); 44 39 40 $checked_free_shipping = ''; 45 41 $asmplsww_free_shipping = get_post_meta($post->ID, 'asmplsww_free_shipping', true); 46 42 if ($asmplsww_free_shipping == 1) { … … 59 55 ); 60 56 61 57 $asmplsww_ship_alone_checked = ''; 62 58 $asmplsww_ship_alone = get_post_meta($post->ID, 'asmplsww_ship_alone', true); 63 59 if ($asmplsww_ship_alone == 1) { … … 130 126 ); 131 127 128 $asmplsww_global_free_ship_exclusion_checked = ''; 132 129 $asmplsww_global_free_ship_exclusion = get_post_meta($post->ID, 'asmplsww_global_free_ship_exclusion', true); 133 130 if ($asmplsww_global_free_ship_exclusion == 1) { … … 220 217 ); 221 218 219 $asmplsww_addons_hazmat_checked = ''; 222 220 $asmplsww_addons_hazmat = get_post_meta($post->ID, 'asmplsww_addons_hazmat', true); 223 221 if ($asmplsww_addons_hazmat == 1) { -
asm-manager/trunk/includes/asmplsww_product_field.php
r2663838 r2848152 2 2 /** 3 3 * @package ASM product field 4 * @version 1.2. 34 * @version 1.2.4 5 5 */ 6 /* 7 8 */ 6 9 7 if (!class_exists('ASMPLSWW_Shipping_Field')) { 10 8 class ASMPLSWW_Admin_Field 11 9 { 12 13 10 public function __construct() 14 11 { 15 16 12 add_filter('woocommerce_product_data_tabs', 'add_asm_product_data_tab'); 17 13 function add_asm_product_data_tab($product_data_tabs) … … 24 20 } 25 21 26 27 22 add_action('woocommerce_product_data_panels', 'add_asm_product_data_fields'); 28 23 function add_asm_product_data_fields() … … 236 231 237 232 echo "</div>"; 238 239 240 233 } 241 242 234 243 235 /** Hook callback function to save custom fields information */ 244 236 function save_asm_product_data_fields($post_id) 245 237 { 246 247 238 // Save Text Field 248 239 $_asm_dimensions = $_POST['_asm_dimensions']; … … 293 284 update_post_meta($post_id, '_asm_addons_item_points', sanitize_text_field($_asm_addons_item_points)); 294 285 295 296 286 $_asm_addons_multi_box_points = $_POST['_asm_addons_multi_box_points']; 297 287 update_post_meta($post_id, '_asm_addons_multi_box_points', sanitize_text_field($_asm_addons_multi_box_points)); … … 317 307 $_asm_addons_options_weight_points = $_POST['_asm_addons_options_weight_points']; 318 308 update_post_meta($post_id, '_asm_addons_options_weight_points', sanitize_textarea_field($_asm_addons_options_weight_points)); 319 320 321 309 } 322 310 323 311 add_action('woocommerce_process_product_meta', 'save_asm_product_data_fields'); 324 325 326 312 } 327 313 } -
asm-manager/trunk/includes/asmplsww_query_live.php
r2663838 r2848152 2 2 /** 3 3 * @package ASM Shipping Api 4 * @version 1.2. 34 * @version 1.2.4 5 5 */ 6 7 /*8 */9 10 6 global $woocommerce; 11 7 12 8 $items = $woocommerce->cart->get_cart(); 13 14 9 15 10 //Box Weight … … 19 14 20 15 foreach ($items as $item => $values) { 21 22 16 //Product is varibale or simple so fetch value as per 23 17 if ($values['variation_id']) { … … 43 37 $NonTaxableProductPrice += ($_product->get_price() * $values['quantity']); 44 38 } 45 46 39 // check taxable value and set amount 47 48 49 40 } 50 41 51 42 //Get Coupon Value 52 if ($woocommerce->cart->get_applied_coupons()['0'] != "") { 43 $coupons_amount = 0; 44 if (isset($woocommerce->cart->get_applied_coupons()['0']) && $woocommerce->cart->get_applied_coupons()['0'] != "") { 53 45 $coupons_obj = new WC_Coupon($woocommerce->cart->get_applied_coupons()['0']); 54 46 $coupons_amount = $woocommerce->cart->get_subtotal() * $coupons_obj->get_amount() / 100; … … 57 49 //Get Coupon Value 58 50 if (wc_tax_enabled() == true) { 59 $TotalTaxable = (($woocommerce->cart->get_subtotal() + $woocommerce->cart->tax_total) - $coupons_amount);51 $TotalTaxable = (($woocommerce->cart->get_subtotal()) - $coupons_amount); 60 52 } 61 53 62 54 //Get Taxable Value 63 55 if ($TaxableProductPrice != "") { 64 $TotalTaxbaleProductPrice = ($TaxableProductPrice + $woocommerce->cart->tax_total);56 $TotalTaxbaleProductPrice = $TaxableProductPrice; 65 57 } 66 58 59 $domainname = ''; 67 60 $pieces = parse_url(home_url()); 68 61 $domain = isset($pieces['host']) ? $pieces['host'] : ''; … … 76 69 <AccountIdentifier>BD8h3Dhs7qj18shr2p</AccountIdentifier> 77 70 <StoreIndicator>" . $domainname . "</StoreIndicator> 78 <Total>" . ($woocommerce->cart->cart_contents_total + $woocommerce->cart->tax_total). "</Total>71 <Total>" . $woocommerce->cart->cart_contents_total . "</Total> 79 72 <TotalTaxable>" . $TotalTaxbaleProductPrice . "</TotalTaxable> 80 73 <TotalNonTaxable>" . $NonTaxableProductPrice . "</TotalNonTaxable> … … 91 84 92 85 foreach ($items as $item => $values) { 93 94 86 //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) { 96 88 $_product = wc_get_product($values['variation_id']); 97 89 $getcmeta = get_post_meta($values['product_id']); … … 104 96 } 105 97 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'] : ''; 108 100 109 101 if ($color != "") { … … 126 118 <Taxable>" . ($_product->get_tax_status() == 'taxable' ? 'Y' : 'N') . "</Taxable> 127 119 <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> 151 143 </Attributes> 152 144 </Product>"; 153 145 } 154 146 155 156 147 $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> 158 149 <CouponValue>" . $coupons_amount . "</CouponValue> 159 150 </ShippingQuery>"; 151 152 function 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 2 2 /** 3 3 * @package ASM Shipping Api 4 * @version 1.2. 34 * @version 1.2.4 5 5 */ 6 6 /* … … 14 14 //shipping method on 15 15 if (!class_exists('ASMPLSWW_Shipping_Api')) { 16 Class ASMPLSWW_Shipping_Api16 class ASMPLSWW_Shipping_Api 17 17 { 18 19 18 private static $ch; 20 19 private static $output; 21 20 private static $url = 'https://www.advancedshippingmanager.com/clients/web_services/asm_web_service.php'; 22 21 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 23 41 public static function asmplswwGetShippingValue($xml_data) 24 42 { 25 43 $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 } 31 51 } 32 52 } -
asm-manager/trunk/includes/asmplsww_shipping_method.php
r2663838 r2848152 2 2 /** 3 3 * @package ASM Shipping Method 4 * @version 1.2. 34 * @version 1.2.4 5 5 */ 6 /*7 */8 9 6 10 7 function asmplsww_shipping_method_init() … … 13 10 class ASMPLSWW_Shipping_Method extends WC_Shipping_Method 14 11 { 15 16 12 public function __construct($instance_id = 0) 17 13 { 18 19 20 14 $this->id = 'asmplsww'; // Id for your shipping method. Should be uunique. 21 15 22 16 // new fields added 23 17 $this->instance_id = absint($instance_id); 24 $this->supports = array(18 $this->supports = array( 25 19 'shipping-zones', 26 20 'instance-settings', … … 39 33 function init() 40 34 { 41 42 35 // Load the settings API 43 36 $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings … … 56 49 $this->instance_form_fields = array( 57 50 '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'), 61 54 'default' => 'yes', 62 'id' => 'asmplsww_enable_disable_shipping',55 'id' => 'asmplsww_enable_disable_shipping', 63 56 ), 64 57 ); … … 67 60 public function calculate_shipping($package = array()) 68 61 { 69 70 62 //live query 71 63 include 'asmplsww_query_live.php'; 72 73 64 74 65 //Shipping API … … 76 67 include_once 'asmplsww_shipping_api.php'; 77 68 } 78 69 79 70 try { 80 71 $shippingValues = ASMPLSWW_Shipping_Api::asmplswwGetShippingValue($xml_data); … … 84 75 wc_add_notice($message, $messageType); 85 76 } 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 }109 77 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 } 121 97 } 122 123 98 } 124 99 } 125 126 100 } -
asm-manager/trunk/readme.txt
r2663838 r2848152 4 4 Donate link: https://wordpress.org 5 5 Requires PHP: 5.2.4 6 Requires at least: 4.07 Tested up to: 5.98 Stable tag: 5.96 Requires at least: 6.0 7 Tested up to: 6.1 8 Stable tag: 1.2.4 9 9 10 10 == Description == … … 68 68 69 69 == Changelog == 70 = 1.2.4 = 71 * PHP v8 supported 72 * Bug fixes 73 70 74 = 1.2.3 = 71 75 * Bug fixes
Note: See TracChangeset
for help on using the changeset viewer.