PHP code example of dickyp / rajaongkir

1. Go to this page and download the library: Download dickyp/rajaongkir library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dickyp / rajaongkir example snippets

sh
php artisan vendor:publish

dalam folder laravel-project/config/config/rajaongkir.php

pindahkan rajaongkir.php ke folder laravel-project/config/ 
sh
RajaOngkir::province();

callback
  0 => array:2 [▼
    "province_id" => "1"
    "province" => "Bali"
  ]
  1 => array:2 [▼
    "province_id" => "2"
    "province" => "Bangka Belitung"
  ]
sh
$id = 1;
RajaOngkir::province($id);

callback
  0 => array:2 [▼
    "province_id" => "1"
    "province" => "Bali"
  ]
sh
$id = 1;
RajaOngkir::city($id)

callback
  0 => array:6 [▼
    "city_id" => "1"
    "province_id" => "21"
    "province" => "Nanggroe Aceh Darussalam (NAD)"
    "type" => "Kabupaten"
    "city_name" => "Aceh Barat"
    "postal_code" => "23681"
  ]
sh
$origin      = $id_city_origin; // id kota pengirim
$destination = $id_city_destination; //id kota penerima
$weight      = 10000;   //dalam satuan gram
$courier     = "jne" bisa di isi kurir lain tergantung tipe akun.
RajaOngkir::shipping($origin, $destination, $weight, $courier);

callback 

  "code" => "jne"
  "name" => "Jalur Nugraha Ekakurir (JNE)"
  "costs" => array:2 [▼
    0 => array:3 [▼
      "service" => "OKE"
      "description" => "Ongkos Kirim Ekonomis"
      "cost" => array:1 [▶]
    ]
    1 => array:3 [▼
      "service" => "REG"
      "description" => "Layanan Reguler"
      "cost" => array:1 [▶]
    ]
  ]