Plugin Directory

Changeset 2937337


Ignore:
Timestamp:
07/12/2023 01:02:50 AM (3 years ago)
Author:
delyva
Message:

v1.1.51

Location:
delyvax/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • delyvax/trunk/delyvax.php

    r2891774 r2937337  
    44    Plugin URI: https://delyva.com
    55    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.49
     6    Version: 1.1.51
    77    Author: Delyva
    88    Author URI: https://delyva.com
     
    1313    defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    1414    define('DELYVAX_API_ENDPOINT', 'https://api.delyva.app/');
    15     define('DELYVAX_PLUGIN_VERSION', '1.1.49');
     15    define('DELYVAX_PLUGIN_VERSION', '1.1.51');
    1616
    1717    require_once plugin_dir_path(__FILE__) . 'functions.php';
  • delyvax/trunk/functions.php

    r2891774 r2937337  
    106106}
    107107
     108function 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
    108119
    109120function delyvax_payment_complete( $order_id ){
     
    136147    //set pickup date, time and delivery date and time
    137148    delyvax_set_pickup_delivery_time($order);
    138 
     149   
    139150    $user = $order->get_user();
    140151
     
    392403            include_once 'includes/delyvax-api.php';
    393404        }
     405
     406        //ignore local_pickup
     407        $shipping_method = delyvax_get_order_shipping_method($order->id);
     408        if($shipping_method == 'local_pickup') return;
     409        //
    394410
    395411        $DelyvaXOrderID = $order->get_meta( 'DelyvaXOrderID');
     
    604620              }
    605621          }
     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;
    606644      }else {
    607645          // echo 'no multivendor';
     
    669707              ),
    670708              "weight" => array(
    671                   "value" => (delyvax_default_weight(delyvaX_weight_to_kg($product_weight))),
     709                  "value" => $product_weight,
    672710                  "unit" => 'kg'
    673711              ),
    674712              "dimension" => array(
    675713                  "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
    679717              ),
    680718              "quantity" => $quantity,
     
    684722          $total_weight = $total_weight + ($product_weight*$quantity);
    685723
    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;
    689727
    690728          $total_price = $total_price + $subtotal;
  • delyvax/trunk/includes/delyvax-shipping.php

    r2891774 r2937337  
    152152                  'SINGLE' => __( 'Single vendor', 'woocommerce' ),
    153153                  'DOKAN' => __( 'Dokan', 'woocommerce' ),
    154                   'WCFM' => __( 'WCFM', 'woocommerce' ),
     154                  'WCFM' => __( 'WCFM', 'woocommerce' )
     155                //   'MKING' => __( 'MarketKing', 'woocommerce' ),
    155156                )
    156157            ),
     
    376377                'type'    => 'select',
    377378                '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' ),
    383384                )
    384385            ),
     
    619620                    }
    620621                }
     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;
    621645            }else {
    622646                // echo 'no multivendor';
     
    755779                              if($free_shipping_type == 'total_quantity')
    756780                              {
    757                                   if($free_shipping_condition == '>')
     781                                  if($free_shipping_condition == '>' || $free_shipping_condition == 'gt')
    758782                                  {
    759783                                      if($total_quantity > $free_shipping_value)
     
    761785                                         $cost = 0;
    762786                                      }
    763                                   }else if($free_shipping_condition == '>=')
     787                                  }else if($free_shipping_condition == '>=' || $free_shipping_condition == 'gte')
    764788                                  {
    765789                                      if($total_quantity >= $free_shipping_value)
     
    767791                                         $cost = 0;
    768792                                      }
    769                                   }else if($free_shipping_condition == '==')
     793                                  }else if($free_shipping_condition == '==' || $free_shipping_condition == 'eq')
    770794                                  {
    771795                                      if($total_quantity == $free_shipping_value)
     
    773797                                         $cost = 0;
    774798                                      }
    775                                   }else if($free_shipping_condition == '<=')
     799                                  }else if($free_shipping_condition == '<=' || $free_shipping_condition == 'lte')
    776800                                  {
    777801                                      if($total_quantity <= $free_shipping_value)
     
    779803                                         $cost = 0;
    780804                                      }
    781                                   }else if($free_shipping_condition == '<')
     805                                  }else if($free_shipping_condition == '<' || $free_shipping_condition == 'lt')
    782806                                  {
    783807                                      if($total_quantity < $free_shipping_value)
     
    788812                              }else if($free_shipping_type == 'total_amount')
    789813                              {
    790                                   if($free_shipping_condition == '>')
     814                                  if($free_shipping_condition == '>' || $free_shipping_condition == 'gt')
    791815                                  {
    792816                                      if($total_amount > $free_shipping_value)
     
    794818                                         $cost = 0;
    795819                                      }
    796                                   }else if($free_shipping_condition == '>=')
     820                                  }else if($free_shipping_condition == '>=' || $free_shipping_condition == 'gte')
    797821                                  {
    798822                                      if($total_amount >= $free_shipping_value)
     
    800824                                         $cost = 0;
    801825                                      }
    802                                   }else if($free_shipping_condition == '==')
     826                                  }else if($free_shipping_condition == '==' || $free_shipping_condition == 'eq')
    803827                                  {
    804828                                      if($total_amount == $free_shipping_value)
     
    806830                                         $cost = 0;
    807831                                      }
    808                                   }else if($free_shipping_condition == '<=')
     832                                  }else if($free_shipping_condition == '<=' || $free_shipping_condition == 'lte')
    809833                                  {
    810834                                      if($total_amount <= $free_shipping_value)
     
    812836                                         $cost = 0;
    813837                                      }
    814                                   }else if($free_shipping_condition == '<')
     838                                  }else if($free_shipping_condition == '<' || $free_shipping_condition == 'lt')
    815839                                  {
    816840                                      if($total_amount < $free_shipping_value)
  • delyvax/trunk/includes/shipping-widget.php

    r2891774 r2937337  
    22defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    33add_action ( 'add_meta_boxes', 'delyvax_add_box' );
    4 // add_action ( 'woocommerce_process_shop_order_meta', 'SaveData');
    5 // add_action( 'woocommerce_order_status_completed', 'GetTrackingCode');
     4add_action( 'save_post', 'delyvax_meta_save' );
    65
    76function delyvax_add_box() {
     
    3231        $company_name = 'Delyva';
    3332    }
     33
     34    //ignore local_pickup
     35    $shipping_method = delyvax_get_order_shipping_method($order->id);
     36    if($shipping_method == 'local_pickup') return;
     37    //
    3438
    3539    $DelyvaXOrderID = $order->get_meta( 'DelyvaXOrderID' );
     
    124128        }
    125129    }
    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                     $TrackingCode
    211                 </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     **/
    236130}
    237131
     
    239133 * Saves the custom meta input
    240134 */
    241 function delyvax_meta_save( $post_id ) {
    242     $order = wc_get_order ( $post_id );
     135function delyvax_meta_save($post_id) {
     136    $order = wc_get_order( $post_id );
    243137
    244138    // Checks save status
     
    251145        return;
    252146    }
    253  
     147
    254148    // Checks for input and sanitizes/saves if needed
    255149    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));
    257153        $order->save();
    258154       
     
    260156        $order->update_status('preparing', 'Order status changed to Preparing.', false);
    261157    }
    262 
    263 }
    264 add_action( 'save_post', 'delyvax_meta_save' );
     158}
    265159
    266160function delyvax_get_order_services( $order ) {
  • delyvax/trunk/readme.txt

    r2891774 r2937337  
    44Requires at least: 5.4
    55Tested up to: 6.1
    6 Stable tag: 1.1.49
     6Stable tag: 1.1.51
    77Requires PHP: 7.2
    88License: GPLv3
     
    3232
    3333== 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.
    3444
    3545= 1.1.49 =
Note: See TracChangeset for help on using the changeset viewer.