Plugin Directory

Changeset 2650104


Ignore:
Timestamp:
12/28/2021 05:46:29 PM (4 years ago)
Author:
oife
Message:

limited carriers to dhl,jumia,kexpress

File:
1 edited

Legend:

Unmodified
Added
Removed
  • shiip/trunk/shiip.php

    r2636352 r2650104  
    1717* Plugin URI:        https://app.goshiip.com/
    1818* Description:       The only shipping app you will ever need for your business. You can “Shiip” with top logistics companies at half their standard rates
    19 * Version:           1.0.3
     19* Version:           1.0.4
    2020* Author:            Shiip LLC
    2121* Author URI:        https://goshiip.com/
     
    4040* Rename this for your plugin and update it as you release new versions.
    4141*/
    42 define( 'SHIIP_VERSION', '1.0.3' );
     42define( 'SHIIP_VERSION', '1.0.4' );
    4343
    4444
     
    914914            }
    915915        }
     916
     917        class WC_ShiipMethod_JUMIA extends WC_Shipping_Method {
     918            /**
     919            * Constructor for your shipping class
     920            *
     921            * @access public
     922            * @return void
     923            */
     924            public function __construct() {
     925                $this->id = 'JUMIA';
     926                $this->init();
     927            }
     928           
     929            /**
     930            * Init your settings
     931            *
     932            * @access public
     933            * @return void
     934            */
     935            public function init() {
     936            }
     937            /**
     938            * calculate_shipping function.
     939            *
     940            * @access public
     941            * @param mixed $package
     942            * @return void
     943            */
     944            public function calculate_shipping($package = array()) {
     945               
     946               
     947                $rates = getRates("jumia",$package);
     948               
     949                $parse =  json_decode($rates);
     950               
     951                $kwikamt = "0";
     952                $estDays = "Same Day Delivery";
     953               
     954                $redisKey = "";
     955                $rateId = "";
     956               
     957               
     958               
     959                if($parse->data->rates == null){
     960                    return ;
     961                }
     962               
     963                $redisKey = $parse->data->redis_key;
     964               
     965               
     966                $rate = $parse->data->rates;
     967               
     968                if($rate->currency == "NGN"){//only show ngn
     969                   
     970                    $estDays = "Same Day Delivery";
     971                   
     972                   
     973                    if($rate->estimated_days == null){
     974                        $kwikamt = $rate->amount;
     975                    }else{
     976                        $estDays = $rate->estimated_days;
     977                        $kwikamt = $rate->amount;
     978                    }
     979                   
     980                    $rateId = $rate->courier->id;
     981                   
     982                }
     983               
     984               
     985                $rate = array(
     986                    'id' => "JUMIA",
     987                    'label' => "JUMIA - " .$estDays,
     988                    'cost' => $kwikamt,
     989                    'calc_tax' => 'per_item',
     990                    'meta_data' => array("rateId" => $rateId,"redisKey" => $redisKey)
     991                );
     992               
     993               
     994                // Register the rate
     995                if(isset($kwikamt) && $kwikamt != NULL && $kwikamt > 0){
     996                    $this->add_rate($rate);
     997                }
     998            }
     999        }
    9161000       
    9171001    }
     
    9241008            //for now this plugin is for only nigerian vendors
    9251009           
    926             $methods['shiip'] = 'WC_ShiipMethod';
     1010            // $methods['shiip'] = 'WC_ShiipMethod';
    9271011            $methods['shiipDHL'] = 'WC_ShiipMethod_DHL';
    928             $methods['shiipFEDEX'] = 'WC_ShiipMethod_FEDEX';
     1012            $methods['shiipJUMIA'] = 'WC_ShiipMethod_JUMIA';
     1013            // $methods['shiipFEDEX'] = 'WC_ShiipMethod_FEDEX';
    9291014            // $methods['shiipGIG'] = 'WC_ShiipMethod_GIG';
    930             $methods['shiipKXPRESSBIKE'] = 'WC_ShiipMethod_KONGABIKE';
     1015            // $methods['shiipKXPRESSBIKE'] = 'WC_ShiipMethod_KONGABIKE';
    9311016            $methods['shiipKXPRESSVAN'] = 'WC_ShiipMethod_KONGAVAN';
    9321017            //  remove gokada for now $methods['shiipGOKADA'] = 'WC_ShiipMethod_GOKADA';
Note: See TracChangeset for help on using the changeset viewer.