Changeset 2937337
- Timestamp:
- 07/12/2023 01:02:50 AM (3 years ago)
- Location:
- delyvax/trunk
- Files:
-
- 5 edited
-
delyvax.php (modified) (2 diffs)
-
functions.php (modified) (6 diffs)
-
includes/delyvax-shipping.php (modified) (13 diffs)
-
includes/shipping-widget.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
delyvax/trunk/delyvax.php
r2891774 r2937337 4 4 Plugin URI: https://delyva.com 5 5 description: The official Delyva plugin helps store owners to integrate WooCommerce with [Delyva](https://delyva.com) for seamless service comparison and order processing. 6 Version: 1.1. 496 Version: 1.1.51 7 7 Author: Delyva 8 8 Author URI: https://delyva.com … … 13 13 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 14 14 define('DELYVAX_API_ENDPOINT', 'https://api.delyva.app/'); 15 define('DELYVAX_PLUGIN_VERSION', '1.1. 49');15 define('DELYVAX_PLUGIN_VERSION', '1.1.51'); 16 16 17 17 require_once plugin_dir_path(__FILE__) . 'functions.php'; -
delyvax/trunk/functions.php
r2891774 r2937337 106 106 } 107 107 108 function delyvax_get_order_shipping_method( $order_id ){ 109 $shipping_method = null; 110 111 $order = wc_get_order( $order_id ); 112 foreach( $order->get_items( 'shipping' ) as $item_id => $item ) 113 { 114 $shipping_method = $item->get_method_id(); 115 } 116 return $shipping_method; 117 } 118 108 119 109 120 function delyvax_payment_complete( $order_id ){ … … 136 147 //set pickup date, time and delivery date and time 137 148 delyvax_set_pickup_delivery_time($order); 138 149 139 150 $user = $order->get_user(); 140 151 … … 392 403 include_once 'includes/delyvax-api.php'; 393 404 } 405 406 //ignore local_pickup 407 $shipping_method = delyvax_get_order_shipping_method($order->id); 408 if($shipping_method == 'local_pickup') return; 409 // 394 410 395 411 $DelyvaXOrderID = $order->get_meta( 'DelyvaXOrderID'); … … 604 620 } 605 621 } 622 }else if($multivendor_option == 'MKING') 623 { 624 $vendor_id = marketking()->get_product_vendor( $product_id ); 625 626 // $company = get_user_meta($vendor_id, 'billing_company', true); 627 $store_name = marketking()->get_store_name_display($vendor_id); 628 // $store_name = get_user_meta($vendor_id, 'marketking_store_name', true); 629 $store_first_name = get_user_meta($vendor_id, 'billing_first_name', true); 630 $store_last_name = get_user_meta($vendor_id, 'billing_last_name', true); 631 $store_phone = get_user_meta($vendor_id, 'billing_phone', true); 632 $store_email = marketking()->get_vendor_email($vendor_id); 633 // $store_email = get_user_meta($vendor_id, 'billing_email', true); 634 635 $store_address_1 = get_user_meta($vendor_id, 'billing_address_1', true); 636 $store_address_2 = get_user_meta($vendor_id, 'billing_address_2', true); 637 $store_city = get_user_meta($vendor_id, 'billing_city', true); 638 $store_state = get_user_meta($vendor_id, 'billing_postcode', true); 639 $store_postcode = get_user_meta($vendor_id, 'billing_state', true); 640 $store_country = get_user_meta($vendor_id, 'billing_country', true); 641 642 // $origin_lat = isset($store_info['address']['lat']) ? $store_info['address']['lat'] : null; 643 // $origin_lon = isset($store_info['address']['lon']) ? $store_info['address']['lon'] : null; 606 644 }else { 607 645 // echo 'no multivendor'; … … 669 707 ), 670 708 "weight" => array( 671 "value" => (delyvax_default_weight(delyvaX_weight_to_kg($product_weight))),709 "value" => $product_weight, 672 710 "unit" => 'kg' 673 711 ), 674 712 "dimension" => array( 675 713 "unit" => 'cm', 676 "width" => (delyvax_default_dimension(delyvax_dimension_to_cm($product_width))),677 "length" => (delyvax_default_dimension(delyvax_dimension_to_cm($product_length))),678 "height" => (delyvax_default_dimension(delyvax_dimension_to_cm($product_height)))714 "width" => $product_width, 715 "length" => $product_length, 716 "height" => $product_height 679 717 ), 680 718 "quantity" => $quantity, … … 684 722 $total_weight = $total_weight + ($product_weight*$quantity); 685 723 686 $total_dimension = $total_dimension + (delyvax_default_dimension(delyvax_dimension_to_cm($product_width))687 * delyvax_default_dimension(delyvax_dimension_to_cm($product_length))688 * delyvax_default_dimension(delyvax_dimension_to_cm($product_height)));724 $total_dimension = $total_dimension + $product_width 725 * $product_length 726 * $product_height; 689 727 690 728 $total_price = $total_price + $subtotal; -
delyvax/trunk/includes/delyvax-shipping.php
r2891774 r2937337 152 152 'SINGLE' => __( 'Single vendor', 'woocommerce' ), 153 153 'DOKAN' => __( 'Dokan', 'woocommerce' ), 154 'WCFM' => __( 'WCFM', 'woocommerce' ), 154 'WCFM' => __( 'WCFM', 'woocommerce' ) 155 // 'MKING' => __( 'MarketKing', 'woocommerce' ), 155 156 ) 156 157 ), … … 376 377 'type' => 'select', 377 378 'options' => array( 378 ' >' => __( 'Greater than', 'woocommerce' ),379 ' >=' => __( 'Greater or equal', 'woocommerce' ),380 ' ==' => __( 'Equal to', 'woocommerce' ),381 ' <=' => __( 'Less than or equal', 'woocommerce' ),382 ' <' => __( 'Less than', 'woocommerce' ),379 'gt' => __( 'Greater than', 'woocommerce' ), 380 'gte' => __( 'Greater or equal', 'woocommerce' ), 381 'eq' => __( 'Equal to', 'woocommerce' ), 382 'lte' => __( 'Less than or equal', 'woocommerce' ), 383 'lt' => __( 'Less than', 'woocommerce' ), 383 384 ) 384 385 ), … … 619 620 } 620 621 } 622 }else if($multivendor_option == 'MKING') 623 { 624 $vendor_id = marketking()->get_product_vendor( $product_id ); 625 626 // $company = get_user_meta($vendor_id, 'billing_company', true); 627 $store_name = marketking()->get_store_name_display($vendor_id); 628 // $store_name = get_user_meta($vendor_id, 'marketking_store_name', true); 629 $store_first_name = get_user_meta($vendor_id, 'billing_first_name', true); 630 $store_last_name = get_user_meta($vendor_id, 'billing_last_name', true); 631 $store_phone = get_user_meta($vendor_id, 'billing_phone', true); 632 // $store_email = get_user_meta($vendor_id, 'billing_email', true); 633 $store_email = marketking()->get_vendor_email($vendor_id); 634 // $store_email = get_user_meta($vendor_id, 'billing_email', true); 635 636 $store_address_1 = get_user_meta($vendor_id, 'billing_address_1', true); 637 $store_address_2 = get_user_meta($vendor_id, 'billing_address_2', true); 638 $store_city = get_user_meta($vendor_id, 'billing_city', true); 639 $store_state = get_user_meta($vendor_id, 'billing_postcode', true); 640 $store_postcode = get_user_meta($vendor_id, 'billing_state', true); 641 $store_country = get_user_meta($vendor_id, 'billing_country', true); 642 643 // $origin_lat = isset($store_info['address']['lat']) ? $store_info['address']['lat'] : null; 644 // $origin_lon = isset($store_info['address']['lon']) ? $store_info['address']['lon'] : null; 621 645 }else { 622 646 // echo 'no multivendor'; … … 755 779 if($free_shipping_type == 'total_quantity') 756 780 { 757 if($free_shipping_condition == '>' )781 if($free_shipping_condition == '>' || $free_shipping_condition == 'gt') 758 782 { 759 783 if($total_quantity > $free_shipping_value) … … 761 785 $cost = 0; 762 786 } 763 }else if($free_shipping_condition == '>=' )787 }else if($free_shipping_condition == '>=' || $free_shipping_condition == 'gte') 764 788 { 765 789 if($total_quantity >= $free_shipping_value) … … 767 791 $cost = 0; 768 792 } 769 }else if($free_shipping_condition == '==' )793 }else if($free_shipping_condition == '==' || $free_shipping_condition == 'eq') 770 794 { 771 795 if($total_quantity == $free_shipping_value) … … 773 797 $cost = 0; 774 798 } 775 }else if($free_shipping_condition == '<=' )799 }else if($free_shipping_condition == '<=' || $free_shipping_condition == 'lte') 776 800 { 777 801 if($total_quantity <= $free_shipping_value) … … 779 803 $cost = 0; 780 804 } 781 }else if($free_shipping_condition == '<' )805 }else if($free_shipping_condition == '<' || $free_shipping_condition == 'lt') 782 806 { 783 807 if($total_quantity < $free_shipping_value) … … 788 812 }else if($free_shipping_type == 'total_amount') 789 813 { 790 if($free_shipping_condition == '>' )814 if($free_shipping_condition == '>' || $free_shipping_condition == 'gt') 791 815 { 792 816 if($total_amount > $free_shipping_value) … … 794 818 $cost = 0; 795 819 } 796 }else if($free_shipping_condition == '>=' )820 }else if($free_shipping_condition == '>=' || $free_shipping_condition == 'gte') 797 821 { 798 822 if($total_amount >= $free_shipping_value) … … 800 824 $cost = 0; 801 825 } 802 }else if($free_shipping_condition == '==' )826 }else if($free_shipping_condition == '==' || $free_shipping_condition == 'eq') 803 827 { 804 828 if($total_amount == $free_shipping_value) … … 806 830 $cost = 0; 807 831 } 808 }else if($free_shipping_condition == '<=' )832 }else if($free_shipping_condition == '<=' || $free_shipping_condition == 'lte') 809 833 { 810 834 if($total_amount <= $free_shipping_value) … … 812 836 $cost = 0; 813 837 } 814 }else if($free_shipping_condition == '<' )838 }else if($free_shipping_condition == '<' || $free_shipping_condition == 'lt') 815 839 { 816 840 if($total_amount < $free_shipping_value) -
delyvax/trunk/includes/shipping-widget.php
r2891774 r2937337 2 2 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 3 3 add_action ( 'add_meta_boxes', 'delyvax_add_box' ); 4 // add_action ( 'woocommerce_process_shop_order_meta', 'SaveData'); 5 // add_action( 'woocommerce_order_status_completed', 'GetTrackingCode'); 4 add_action( 'save_post', 'delyvax_meta_save' ); 6 5 7 6 function delyvax_add_box() { … … 32 31 $company_name = 'Delyva'; 33 32 } 33 34 //ignore local_pickup 35 $shipping_method = delyvax_get_order_shipping_method($order->id); 36 if($shipping_method == 'local_pickup') return; 37 // 34 38 35 39 $DelyvaXOrderID = $order->get_meta( 'DelyvaXOrderID' ); … … 124 128 } 125 129 } 126 127 /**128 if ($TrackingCode == 'Service Unavailable') {129 echo 'Tracking No.: <b>'.$TrackingCode.'</b>';130 echo "<div><p>Failed to create shipment in ".$company_name.", you can try again by changing order status to <b>Preparing</b></p></div>";131 } else if ( $order->has_status(array('processing')) || $order->has_status( array( 'on-hold' )) ) {132 $DelyvaXServices = $order->get_meta( 'DelyvaXServices' );133 134 $adxservices = array();135 136 if($DelyvaXOrderID && !$DelyvaXServices)137 {138 $order = delyvax_get_order_services($order);139 $DelyvaXServices = $order->get_meta( 'DelyvaXServices' );140 }141 142 if($DelyvaXServices)143 {144 $adxservices = json_decode($DelyvaXServices);145 }146 147 if($DelyvaXError) {148 echo "Error: ".$DelyvaXError;149 }150 151 if($TrackingCode)152 {153 echo 'Tracking No.: <b>'.$TrackingCode.'</b>';154 echo "<div>155 <p>156 Set your order to <b>Preparing</b> to print label and track your shipment with ".$company_name.".157 </p>158 </div>";159 echo "<div><p>160 <a href=\"".wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=preparing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' )."\" class=\"button button-primary\">Set to Preparing</a>161 </p></div>";162 }163 164 if(sizeof($adxservices) > 0) {165 delyvax_get_services_select($adxservices, $DelyvaXServiceCode);166 167 echo '<p><button class="button button-primary" type="submit">Fulfill with '.$company_name.'</button></p>';168 }169 170 // if($create_shipment_on_confirm == 'yes')171 // {172 // // echo "<div><p>173 // // <a href=\"".wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=preparing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' )."\" class=\"button button-primary\">Fulfill with ".$company_name."</a>174 // // </p></div>";175 // }else {176 // // echo "<div><p>177 // // <a href=\"".wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=preparing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' )."\" class=\"button button-primary\">Fulfill with ".$company_name."</a>178 // // </p></div>";179 // }180 } else if ( $order->has_status( array( 'preparing' )) || $order->has_status( array( 'ready-to-collect' )) ) {181 182 if($DelyvaXError) {183 echo "Error: ".$DelyvaXError;184 }185 if($TrackingCode)186 {187 echo 'Tracking No.: <b>'.$TrackingCode.'</b>';188 echo "<div><p>189 <a href=\"".$printLabelUrl."\" class=\"button button-primary\" target=\"_blank\">Print label</a>190 </p></div>";191 echo "<div><p>192 <a href=\"".$trackUrl."\" class=\"button button-primary\" target=\"_blank\">Track shipment</a>193 </p></div>";194 }else {195 echo "<div>196 <p>197 Set your order to <b>Processing</b> again to fulfill with ".$company_name.", it also works with <i>bulk actions</i> too!198 </p>199 </div>";200 echo "<div><p>201 <a href=\"".wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=processing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' )."\" class=\"button button-primary\">Set to Processing</a>202 </p></div>";203 }204 } else if ( $order->has_status( array( 'completed' ) ) && $TrackingCode ) {205 echo 'Tracking No.: <b>'.$TrackingCode.'</b>';206 echo "<div>207 <p>208 <label for=\"TrackingCode\"> Tracking No :</label>209 <br />210 $TrackingCode211 </p>212 </div>";213 // echo "<div><p>214 // <a href=\"".$printLabelUrl."\" class=\"button button-primary\" target=\"_blank\">Print label</a>215 // </p></div>";216 echo "<div><p>217 <a href=\"".$trackUrl."\" class=\"button button-primary\" target=\"_blank\">Track shipment</a>218 </p></div>";219 } else if($TrackingCode){220 echo 'Tracking No.: <b>'.$TrackingCode.'</b>';221 echo "<div><p>222 <a href=\"".$printLabelUrl."\" class=\"button button-primary\" target=\"_blank\">Print label</a>223 </p></div>";224 echo "<div><p>225 <a href=\"".$trackUrl."\" class=\"button button-primary\" target=\"_blank\">Track shipment</a>226 </p></div>";227 } else{228 229 echo "<div>230 <p>231 Set your order to <b>Processing</b> to fulfill with ".$company_name.", it also works with <i>bulk actions</i> too!232 </p>233 </div>";234 }235 **/236 130 } 237 131 … … 239 133 * Saves the custom meta input 240 134 */ 241 function delyvax_meta_save( $post_id) {242 $order = wc_get_order( $post_id );135 function delyvax_meta_save($post_id) { 136 $order = wc_get_order( $post_id ); 243 137 244 138 // Checks save status … … 251 145 return; 252 146 } 253 147 254 148 // Checks for input and sanitizes/saves if needed 255 149 if( isset( $_POST[ 'service_code' ] ) ) { 256 $order->update_meta_data( 'DelyvaXServiceCode', sanitize_text_field( $_POST[ 'service_code' ] ) ); 150 echo $service_code = $_POST[ 'service_code' ]; 151 152 $order->update_meta_data('DelyvaXServiceCode',sanitize_text_field($service_code)); 257 153 $order->save(); 258 154 … … 260 156 $order->update_status('preparing', 'Order status changed to Preparing.', false); 261 157 } 262 263 } 264 add_action( 'save_post', 'delyvax_meta_save' ); 158 } 265 159 266 160 function delyvax_get_order_services( $order ) { -
delyvax/trunk/readme.txt
r2891774 r2937337 4 4 Requires at least: 5.4 5 5 Tested up to: 6.1 6 Stable tag: 1.1. 496 Stable tag: 1.1.51 7 7 Requires PHP: 7.2 8 8 License: GPLv3 … … 32 32 33 33 == Changelog == 34 35 = 1.1.51 = 36 *Release Date - 12th July 2023* 37 38 * Fixes regarding non-kg product weight and product variances. 39 40 = 1.1.50 = 41 *Release Date - 29th May 2023* 42 43 * Ignore localpickup shipping method and fix free shipping conditions. 34 44 35 45 = 1.1.49 =
Note: See TracChangeset
for help on using the changeset viewer.