Plugin Directory

Changeset 2633255


Ignore:
Timestamp:
11/22/2021 03:21:47 AM (4 years ago)
Author:
delyva
Message:

v1.1.21

Location:
delyvax/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • delyvax/trunk/delyvax.php

    r2611032 r2633255  
    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.20
     6    Version: 1.1.21
    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.20');
     15    define('DELYVAX_PLUGIN_VERSION', '1.1.21');
    1616
    1717    require_once plugin_dir_path(__FILE__) . 'functions.php';
  • delyvax/trunk/functions.php

    r2594780 r2633255  
    7777    delete_option('delyvax_rate_adjustment_percentage');
    7878    delete_option('delyvax_rate_adjustment_flat');
     79    delete_option('delyvax_multivendor');
    7980}
    8081
     
    159160    $processing_hours = $settings['processing_hours'];
    160161    $processing_time = $settings['processing_time'];
    161     $pickup_minutes = $settings['pickup_minutes'];
    162162
    163163    $gmtoffset = get_option('gmt_offset');
     
    259259        }else if($processing_days > 0 && $processing_time != '')
    260260        {
     261            $processing_time = str_replace(":00","",$processing_time);
     262
    261263            $delivery_time = $delivery_date;
    262264            $delivery_time->setTime($processing_time,00,00);
     
    307309            $dx_pickup_date_format = $dx_delivery_date_format;
    308310        }
    309 
    310         //set pickup time
    311         if($order->get_meta( 'dx_pickup_time' ) != null)
    312         {
    313             $dx_pickup_time = $order->get_meta( 'dx_pickup_time' );
    314         }else if($pickup_minutes > 0)
    315         {
    316             $pickup_time = $delivery_time;
    317             $pickup_time->sub(new DateInterval('PT'.$pickup_minutes.'M'));
    318 
    319             $dx_pickup_time = $pickup_time->format('H:i');
    320         }else {
    321             //minus 30 minutes
    322             $pickup_time = $delivery_time;
    323             $pickup_time->sub(new DateInterval('PT30M'));
    324 
    325             $dx_pickup_time = $pickup_time->format('H:i');
    326         }
    327 
    328311    } catch(Exception $e) {
    329312          echo 'Message: ' .$e->getMessage();
     
    378361      $processing_hours = $settings['processing_hours'];
    379362      $item_type = ($settings['item_type']) ? $settings['item_type'] : "PARCEL" ;
     363
     364      $multivendor_option = $settings['multivendor'];
    380365
    381366      //----delivery date & time (pull from meta data), if not available, set to +next day 8am.
     
    507492
    508493              //store info
    509               if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
     494              if($multivendor_option == 'DOKAN')
    510495              {
    511                   $seller_id = dokan_get_seller_id_by_order($sub_order->get_id());
    512                   $store_info = dokan_get_store_info( $seller_id );
    513 
    514                   $product_store_name = $store_info['store_name'];
    515 
    516                   if($store_info['store_name']) $store_name = $store_info['store_name'];
    517                   if($store_info['first_name']) $store_first_name = $store_info['first_name'];
    518                   if($store_info['last_name']) $store_last_name = $store_info['last_name'];
    519                   if($store_info['phone']) $store_phone = $store_info['phone'];
    520                   if($store_info['email']) $store_email = $store_info['email'];
    521                   $store_address_1 = $store_info['address']['street_1'];
    522                   $store_address_2 = $store_info['address']['street_2'];
    523                   $store_city = $store_info['address']['city'];
    524                   $store_state = $store_info['address']['state'];
    525                   $store_postcode = $store_info['address']['zip'];
    526                   $store_country = $store_info['address']['country'];
    527 
    528               }else if(function_exists(wcfm_get_vendor_id_by_post))
     496                  if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
     497                  {
     498                      $seller_id = dokan_get_seller_id_by_order($sub_order->get_id());
     499                      $store_info = dokan_get_store_info( $seller_id );
     500
     501                      $product_store_name = $store_info['store_name'];
     502
     503                      if($store_info['store_name']) $store_name = $store_info['store_name'];
     504                      if($store_info['first_name']) $store_first_name = $store_info['first_name'];
     505                      if($store_info['last_name']) $store_last_name = $store_info['last_name'];
     506                      if($store_info['phone']) $store_phone = $store_info['phone'];
     507                      if($store_info['email']) $store_email = $store_info['email'];
     508                      $store_address_1 = $store_info['address']['street_1'];
     509                      $store_address_2 = $store_info['address']['street_2'];
     510                      $store_city = $store_info['address']['city'];
     511                      $store_state = $store_info['address']['state'];
     512                      $store_postcode = $store_info['address']['zip'];
     513                      $store_country = $store_info['address']['country'];
     514                  }
     515              }else if($multivendor_option == 'WCFM')
    529516              {
    530                           $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
    531 
    532                   $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
    533 
    534                   if($store_info)
     517                  if(function_exists(wcfm_get_vendor_id_by_post))
    535518                  {
    536                       $product_store_name = $store_name = $store_info['store_name'];
    537                       $store_first_name = $store_info['store_name'];
    538                       $store_last_name = $store_info['store_name'];
    539                       $store_phone = $store_info['phone'];
    540                       $store_email = $store_info['store_email'];
    541                       $store_address_1 = isset( $store_info['address']['street_1'] ) ? $store_info['address']['street_1'] : '';
    542                       $store_address_2 = isset( $store_info['address']['street_2'] ) ? $store_info['address']['street_2'] : '';
    543                       $store_city     = isset( $store_info['address']['city'] ) ? $store_info['address']['city'] : '';
    544                       $store_state    = isset( $store_info['address']['state'] ) ? $store_info['address']['state'] : '';
    545                       $store_postcode      = isset( $store_info['address']['zip'] ) ? $store_info['address']['zip'] : '';
    546                       $store_country  = isset( $store_info['address']['country'] ) ? $store_info['address']['country'] : '';
     519                          $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
     520
     521                    $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
     522
     523                    if($store_info)
     524                    {
     525                        $product_store_name = $store_name = $store_info['store_name'];
     526                        $store_first_name = $store_info['store_name'];
     527                        $store_last_name = $store_info['store_name'];
     528                        $store_phone = $store_info['phone'];
     529                        $store_email = $store_info['store_email'];
     530                        $store_address_1 = isset( $store_info['address']['street_1'] ) ? $store_info['address']['street_1'] : '';
     531                        $store_address_2 = isset( $store_info['address']['street_2'] ) ? $store_info['address']['street_2'] : '';
     532                        $store_city     = isset( $store_info['address']['city'] ) ? $store_info['address']['city'] : '';
     533                        $store_state    = isset( $store_info['address']['state'] ) ? $store_info['address']['state'] : '';
     534                        $store_postcode      = isset( $store_info['address']['zip'] ) ? $store_info['address']['zip'] : '';
     535                        $store_country  = isset( $store_info['address']['country'] ) ? $store_info['address']['country'] : '';
     536                    }
    547537                  }
    548538              }else {
     
    578568                      $variation = $_pf->get_product( $product_variation_id );
    579569
    580                       $product_name = $variation->get_name();
    581                       $product_weight = $variation->get_weight();
    582                       $product_length = $variation->get_length();
    583                       $product_width = $variation->get_width();
    584                       $product_height = $variation->get_height();
     570                      if($variation)
     571                      {
     572                          $product_name = $variation->get_name();
     573                          $product_weight = $variation->get_weight();
     574                          $product_length = $variation->get_length();
     575                          $product_width = $variation->get_width();
     576                          $product_height = $variation->get_height();
     577                      }else {
     578                          $product_weight = $product->get_weight();
     579                          $product_length = $product->get_length();
     580                          $product_width = $product->get_width();
     581                          $product_height = $product->get_height();
     582                      }
    585583                  }else{
    586584                      $product_weight = $product->get_weight();
     
    632630              }
    633631
    634           if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
     632          if($multivendor_option == 'DOKAN')
    635633          {
    636               $seller_id = dokan_get_seller_id_by_order($main_order->get_id());
    637               $store_info = dokan_get_store_info( $seller_id );
    638 
    639               $product_store_name = $store_info['store_name'];
    640 
    641               if($store_info['store_name']) $store_name = $store_info['store_name'];
    642               if($store_info['first_name']) $store_first_name = $store_info['first_name'];
    643               if($store_info['last_name']) $store_last_name = $store_info['last_name'];
    644               if($store_info['phone']) $store_phone = $store_info['phone'];
    645               if($store_info['email']) $store_email = $store_info['email'];
    646               $store_address_1 = $store_info['address']['street_1'];
    647               $store_address_2 = $store_info['address']['street_2'];
    648               $store_city = $store_info['address']['city'];
    649               $store_state = $store_info['address']['state'];
    650               $store_postcode = $store_info['address']['zip'];
    651               $store_country = $store_info['address']['country'];
    652           }else if(function_exists(wcfm_get_vendor_id_by_post))
     634              if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
     635              {
     636                  $seller_id = dokan_get_seller_id_by_order($main_order->get_id());
     637                  $store_info = dokan_get_store_info( $seller_id );
     638
     639                  $product_store_name = $store_info['store_name'];
     640
     641                  if($store_info['store_name']) $store_name = $store_info['store_name'];
     642                  if($store_info['first_name']) $store_first_name = $store_info['first_name'];
     643                  if($store_info['last_name']) $store_last_name = $store_info['last_name'];
     644                  if($store_info['phone']) $store_phone = $store_info['phone'];
     645                  if($store_info['email']) $store_email = $store_info['email'];
     646                  $store_address_1 = $store_info['address']['street_1'];
     647                  $store_address_2 = $store_info['address']['street_2'];
     648                  $store_city = $store_info['address']['city'];
     649                  $store_state = $store_info['address']['state'];
     650                  $store_postcode = $store_info['address']['zip'];
     651                  $store_country = $store_info['address']['country'];
     652              }
     653          }else if($multivendor_option == 'WCFM')
    653654          {
    654               $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
    655 
    656               $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
    657 
    658               if($store_info)
     655              if(function_exists(wcfm_get_vendor_id_by_post))
    659656              {
    660                   $product_store_name = $store_name = $store_info['store_name'];
    661                   $store_first_name = $store_info['store_name'];
    662                   $store_last_name = $store_info['store_name'];
    663                   $store_phone = $store_info['phone'];
    664                   $store_email = $store_info['store_email'];
    665                   $store_address_1 = isset( $store_info['address']['street_1'] ) ? $store_info['address']['street_1'] : '';
    666                   $store_address_2 = isset( $store_info['address']['street_2'] ) ? $store_info['address']['street_2'] : '';
    667                   $store_city     = isset( $store_info['address']['city'] ) ? $store_info['address']['city'] : '';
    668                   $store_state    = isset( $store_info['address']['state'] ) ? $store_info['address']['state'] : '';
    669                   $store_postcode      = isset( $store_info['address']['zip'] ) ? $store_info['address']['zip'] : '';
    670                   $store_country  = isset( $store_info['address']['country'] ) ? $store_info['address']['country'] : '';
     657                  $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
     658
     659                  $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
     660
     661                  if($store_info)
     662                  {
     663                      $product_store_name = $store_name = $store_info['store_name'];
     664                      $store_first_name = $store_info['store_name'];
     665                      $store_last_name = $store_info['store_name'];
     666                      $store_phone = $store_info['phone'];
     667                      $store_email = $store_info['store_email'];
     668                      $store_address_1 = isset( $store_info['address']['street_1'] ) ? $store_info['address']['street_1'] : '';
     669                      $store_address_2 = isset( $store_info['address']['street_2'] ) ? $store_info['address']['street_2'] : '';
     670                      $store_city     = isset( $store_info['address']['city'] ) ? $store_info['address']['city'] : '';
     671                      $store_state    = isset( $store_info['address']['state'] ) ? $store_info['address']['state'] : '';
     672                      $store_postcode      = isset( $store_info['address']['zip'] ) ? $store_info['address']['zip'] : '';
     673                      $store_country  = isset( $store_info['address']['country'] ) ? $store_info['address']['country'] : '';
     674                  }
    671675              }
    672676          }else {
     
    705709                  $variation = $_pf->get_product( $product_variation_id );
    706710
    707                   $product_name = $variation->get_name();
    708                   $product_weight = $variation->get_weight();
    709                   $product_length = $variation->get_length();
    710                   $product_width = $variation->get_width();
    711                   $product_height = $variation->get_height();
    712 
     711                  if($variation)
     712                  {
     713                      $product_name = $variation->get_name();
     714                      $product_weight = $variation->get_weight();
     715                      $product_length = $variation->get_length();
     716                      $product_width = $variation->get_width();
     717                      $product_height = $variation->get_height();
     718                  }else {
     719                      $product_weight = $product->get_weight();
     720                      $product_length = $product->get_length();
     721                      $product_width = $product->get_width();
     722                      $product_height = $product->get_height();
     723                  }
    713724              }else{
    714725                  $product_weight = $product->get_weight();
  • delyvax/trunk/includes/delyvax-shipping.php

    r2611032 r2633255  
    6262            ),
    6363            'create_shipment_on_paid' => array(
    64                 'title'     => __( 'Auto Create Delivery Order on Payment Complete', 'delyvax' ),
     64                'title'     => __( 'Fulfil orders immediately', 'delyvax' ),
    6565                'id'        => 'delyvax_create_shipment_on_paid',
    6666                'description'   => __( 'Create paid delivery order on successful payment by customer. If you do not select this, system will create delivery order as draft upon payment complete.', 'delyvax' ),
     
    6969            ),
    7070            'create_shipment_on_confirm' => array(
    71                 'title'     => __( 'Manual Create Delivery Order on Preparing', 'delyvax' ),
     71                'title'     => __( 'Fulfil orders on "Preparing" status', 'delyvax' ),
    7272                'id'        => 'delyvax_create_shipment_on_confirm',
    7373                'description'   => __( 'Create paid delivery on order status = "preparing" by Store/Merchant/Vendor. If you do not select this, system will create delivery order as draft upon changes to preparing status.', 'delyvax' ),
     
    144144                'id' => 'delyvax_shop_email',
    145145                'description' => __( 'e.g. your@email.com' ),
     146            ),
     147            'multivendor' => array(
     148                'title'     => __( 'Multi-vendor system', 'delyvax' ),
     149                'default' => __('SINGLE', 'delyvax'),
     150                'id' => 'delyvax_multivendor',
     151                'description' => __( '' ),
     152                'type'    => 'select',
     153                'options' => array(
     154                  'SINGLE' => __( 'Single vendor', 'woocommerce' ),
     155                  'DOKAN' => __( 'Dokan', 'woocommerce' ),
     156                  'WCFM' => __( 'WCFM', 'woocommerce' ),
     157                )
    146158            ),
    147159            'processing_days' => array(
     
    259271                'description' => __( 'Leave empty or type `woocommerce` or your web design agency code.' ),
    260272            ),
    261             // 'task_item_type' => array(
    262             //     'title'      => __( 'Default Task - Item type', 'delyvax' ),
    263             //     'type' => 'text',
    264             //     'default' => __('0', 'delyvax'),
    265             //     'id' => 'delyvax_task_item_type',
    266             //     'description' => __( 'Default task - package item type. e.g. DOCUMENT / PARCEL / FOOD / PACKAGE.' ),
    267             // ),
    268             // 'split_tasks' => array(
    269             //     'title'      => __( 'Fulfilment by vendors', 'delyvax' ),
    270             //     'id'         => 'delyvax_split_tasks',
    271             //     'description'    => __( 'Create tasks and assign to vendors by ext id type and ext id', 'delyvax' ),
    272             //     'type'       => 'checkbox',
    273             //     'default'    => ''
    274             // ),
    275             // 'ext_id_type' => array(
    276             //     'title'      => __( 'Personnel External ID Type', 'delyvax' ),
    277             //     'type' => 'text',
    278             //     'default'    => '',
    279             //     'id'         => 'delyvax_ext_id_type',
    280             //     'description'    => __( 'Personnel External ID Type. e.g. dokan', 'delyvax' ),
    281             // ),
    282             // 'pickup_minutes' => array(
    283             //     'title'      => __( 'Fulfilment minutes before delivery', 'delyvax' ),
    284             //     'type' => 'text',
    285             //     'default' => __('0', 'delyvax'),
    286             //     'id' => 'delyvax_processing_hours',
    287             //     'description' => __( 'Number of minutes before delivery. e.g. 30 - 30 minutes befor delivery time; 60 - 60 minutes befor delivery time.' ),
    288             // ),
    289             // 'api_webhook_key' => array(
    290             //     'title' => __('API API Webhook Key', 'delyvax'),
    291             //     'type' => 'text',
    292             //     'default' => __('', 'delyvax'),
    293             //     'id' => 'delyvax_api_webhook_key',
    294             //     'description' => __( 'Do not touch this. We will automatically update this field once the system subscribed to DelyvaX webhook.'),
    295             // ),
    296273            array(
    297274                'title' => __( 'Shipping Rate Adjustments', 'delyvax' ),
     
    334311      {
    335312            $status_allow_checkout = true;
     313
     314            $settings = get_option( 'woocommerce_delyvax_settings' );
     315            $multivendor_option = $settings['multivendor'];
    336316
    337317            $pdestination = $package["destination"];
     
    444424            $volumetric_constant = $settings['volumetric_constant'] ?? '5000';
    445425
    446             if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
     426            if($multivendor_option == 'DOKAN')
    447427            {
    448                 $seller_id = $package['seller_id'];
    449 
    450                 if($seller_id)
     428                if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
    451429                {
    452                     $store_info = dokan_get_store_info( $seller_id );
     430                    $seller_id = $package['seller_id'];
     431
     432                    if($seller_id)
     433                    {
     434                        $store_info = dokan_get_store_info( $seller_id );
     435                        if($store_info)
     436                        {
     437                            $store_name = $store_info['store_name'];
     438                            $store_first_name = $store_info['first_name'];
     439                            $store_last_name = $store_info['last_name'];
     440                            $store_phone = $store_info['phone'];
     441                            $store_email = $store_info['email'];
     442                            $store_address_1 = $store_info['address']['street_1'];
     443                            $store_address_2 = $store_info['address']['street_2'];
     444                            $store_city = $store_info['address']['city'];
     445                            $store_state = $store_info['address']['state'];
     446                            $store_postcode = $store_info['address']['zip'];
     447                            $store_country = $store_info['address']['country'];
     448                        }
     449                    }
     450                }
     451            }else if($multivendor_option == 'DOKAN')
     452            {
     453                if(function_exists(wcfm_get_vendor_id_by_post))
     454                {
     455                    $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
     456
     457                    $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
     458
    453459                    if($store_info)
    454460                    {
    455461                        $store_name = $store_info['store_name'];
    456                         $store_first_name = $store_info['first_name'];
    457                         $store_last_name = $store_info['last_name'];
     462                        $store_first_name = $store_info['store_name'];
     463                        $store_last_name = $store_info['store_name'];
    458464                        $store_phone = $store_info['phone'];
    459                         $store_email = $store_info['email'];
    460                         $store_address_1 = $store_info['address']['street_1'];
    461                         $store_address_2 = $store_info['address']['street_2'];
    462                         $store_city = $store_info['address']['city'];
    463                         $store_state = $store_info['address']['state'];
    464                         $store_postcode = $store_info['address']['zip'];
    465                         $store_country = $store_info['address']['country'];
    466                     }
    467                 }
    468             }else if(function_exists(wcfm_get_vendor_id_by_post))
    469             {
    470                 $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
    471 
    472                 $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
    473 
    474                 if($store_info)
    475                 {
    476                     $store_name = $store_info['store_name'];
    477                     $store_first_name = $store_info['store_name'];
    478                     $store_last_name = $store_info['store_name'];
    479                     $store_phone = $store_info['phone'];
    480                     $store_email = $store_info['store_email'];
    481                     $store_address_1 = isset( $store_info['address']['street_1'] ) ? $store_info['address']['street_1'] : '';
    482                     $store_address_2 = isset( $store_info['address']['street_2'] ) ? $store_info['address']['street_2'] : '';
    483                     $store_city     = isset( $store_info['address']['city'] ) ? $store_info['address']['city'] : '';
    484                     $store_state    = isset( $store_info['address']['state'] ) ? $store_info['address']['state'] : '';
    485                     $store_postcode      = isset( $store_info['address']['zip'] ) ? $store_info['address']['zip'] : '';
    486                     $store_country  = isset( $store_info['address']['country'] ) ? $store_info['address']['country'] : '';
     465                        $store_email = $store_info['store_email'];
     466                        $store_address_1 = isset( $store_info['address']['street_1'] ) ? $store_info['address']['street_1'] : '';
     467                        $store_address_2 = isset( $store_info['address']['street_2'] ) ? $store_info['address']['street_2'] : '';
     468                        $store_city     = isset( $store_info['address']['city'] ) ? $store_info['address']['city'] : '';
     469                        $store_state    = isset( $store_info['address']['state'] ) ? $store_info['address']['state'] : '';
     470                        $store_postcode      = isset( $store_info['address']['zip'] ) ? $store_info['address']['zip'] : '';
     471                        $store_country  = isset( $store_info['address']['country'] ) ? $store_info['address']['country'] : '';
     472                    }
    487473                }
    488474            }else {
     
    588574            foreach ($services as $shipper) {
    589575                if (isset($shipper['service']['name'])) {
    590                     $settings = get_option( 'woocommerce_delyvax_settings' );
    591576
    592577                    $rate_adjustment_type = $settings['rate_adjustment_type'] ?? 'discount';
  • delyvax/trunk/readme.txt

    r2611032 r2633255  
    44Requires at least: 5.4
    55Tested up to: 5.7
    6 Stable tag: 1.1.20
     6Stable tag: 1.1.21
    77Requires PHP: 7.2
    88License: GPLv3
     
    3131
    3232== Changelog ==
     33
     34= 1.1.21 =
     35*Release Date - 8 Nov 2021*
     36
     37* Option for Multi-vendor Dokan and WCFM. After updates, Dokan and WCFM users need to set 'Multi-vendor system' to Dokan or WCFM in the plugin setting.
    3338
    3439= 1.1.20 =
Note: See TracChangeset for help on using the changeset viewer.