ImmanuelJL / prestashop-ongkir-mycarrier_rj

My Carrier RJ, hitung ongkir jasa pengiriman barang atau ekspedisi via Jalur Nugraha Ekakurir (JNE), TIKI (Citra Van Titipan Kilat), POS (POS Indonesia). Menggunakan API dari https://rajaongkir.com. Module untuk prestashop GRATIS buatan Immanuel Julianto Lasmana, untuk dokumentasi cek http://immanueljl.blogspot.co.id
GNU General Public License v2.0
8 stars 8 forks source link

Batch pull request. #9

Closed mforsetti closed 4 years ago

mforsetti commented 4 years ago

Batch Pull to Upstream

This pull request contains a few improvements and fixes:

  1. Cleaning up code, removing unneeded comments and refactoring copy-pasted codes, and adding PHPDoc.
  2. All order weight in the module is now in grams, rather than kilograms.
  3. Changed line ending to Linux's (\n rather than \r\n). Should help with vim, diff, and also reduces file size (\r\n takes 2 bytes, while \n takes one).
  4. Coupling mycarrier_rj->$_carriers tighter into the module, preventing multiple edits into the code if somehow anything changes.
  5. Proofreads multiple strings and moving constants into __construct()s and class attributes.
  6. Moving cURL code into a specialized method, checkRajaOngkirApi().
  7. Moving multiple checks on getOrderShippingCost() before processing anything to prevent unnecessary I/O and database access.
  8. Now getOrderShippingCost() much more efficient and only do one cURL request. Previously, for every call to getOrderShippingCost(), module will do 3 requests to RajaOngkir API, process the entire requests, returns one partial result from one of the request, and just dumps another request responses to GC entirely. Add to cart and Checkout should feel snappier, in our case, reduces from 4+ seconds to <1 seconds.

TODO:

  1. Unify module configs. Right now, module configurations are stored in database and PrestaShop's Configuration object.
  2. List of Cities used are stored in JSON file. Probably use the file as a last resort and pre-fetch city list data from RajaOngkir API. Probably consider MySQL table and/or new JSON file to store the data.
  3. Improve RajaOngkir API results cache, because not every installations having good Cache object (e.g. Memcache, APC, etc). Probably store it in MySQL table, and do not store overall API response.
  4. What to do if RajaOngkir API is down, because right now, if RajaOngkir API is down, module will return delivery fee as Free.
  5. Handle higher-tier RajaOngkir API account.