foreach ($row['tarif'] as $layanan => $tarif) { /* buat output table baris */ $etd = isset($tarif['etd']) ? $tarif['etd'] : 'N/A'; if ($first == $layanan) { $output .= ' <tr> <td rowspan="' . $count . '" class="row-center">' . $row['provinsi'] . '</td> <td rowspan="' . $count . '" class="row-center">' . JNE_normalize($row['kota']) . '</td> <td rowspan="' . $count . '" class="row-center">' . JNE_normalize($row['kecamatan']) . '</td> <td class="text-center">' . strtoupper($layanan) . '</td> <td class="text-center">' . JNE_rupiah($tarif['harga']) . '</td> <td class="text-center">' . $etd . '</td> </tr>'; } else { $output .= ' <tr> <td class="text-center">' . strtoupper($layanan) . '</td> <td class="text-center">' . JNE_rupiah($tarif['harga']) . '</td> <td class="text-center">' . $etd . '</td> </tr>'; } } } $x++; } // ajax pagination $paging['pages'] = ceil($paging['total'] / $paging['limit']); $paging['page'] = intval($paging['offset'] / $paging['limit']) + 1; // output pagination numbers $anchor = JNE_pagination($paging, 10); include 'table-data-new.php';
$first = array_shift(array_keys($row['tarif'])); // ambil array key elemen pertama $count = count($row['tarif']); // jumlah data tarif foreach ($row['tarif'] as $layanan => $tarif) { /* buat output table */ if ($first == $layanan) { $output .= ' <tr> <td rowspan="' . $count . '" class="row-center">' . sprintf('%s, %s', $row['provinsi']['nama'], $row['kotamadya']) . '</td> <td rowspan="' . $count . '" class="row-center">' . JNE_normalize($row['kecamatan']) . '</td> <td class="text-center">' . strtoupper($layanan) . '</td> <td class="text-center">' . JNE_rupiah($tarif) . '</td> </tr>'; } else { $output .= ' <tr> <td class="text-center">' . strtoupper($layanan) . '</td> <td class="text-center">' . JNE_rupiah($tarif) . '</td> </tr>'; } } } $x++; } // ajax pagination $paging['pages'] = ceil($paging['total'] / $paging['limit']); $paging['page'] = intval($paging['offset'] / $paging['limit']) + 1; // output pagination numbers $anchor = JNE_pagination($paging, 5); include 'table-data.php';
public function calculate_shipping($package = array()) { global $woocommerce, $jne; if ($this->_chosen_city !== false && sizeof($woocommerce->cart->cart_contents) > 0) { $index_kota = $this->_chosen_city; $carts = $woocommerce->cart->cart_contents; // hitung berat total $total_weight = $this->_calculate_weight($carts); if ($taxes = $jne->getTax($index_kota)) { foreach ($taxes as $layanan => $tarif) { // hitung tarif per berat item $harga = $tarif['harga']; $cost = $harga * $total_weight; // daftarkan tarif $rate = array('id' => $this->id . '_' . $layanan, 'label' => sprintf('%s (<a href="#shipping_method" class="btn btn-success tooltip-jne-weight" rel="popover" data-content="It\'s so simple to create a tooltop for my website!" data-original-title="Twitter Bootstrap Popover">%s kg</a> x %s)', $this->title . ' ' . strtoupper($layanan), $total_weight, JNE_rupiah($harga)), 'cost' => $cost); $this->add_rate($rate); } // print tooltip content if ($this->_show_tooltip) { echo '<div id="weight-details" style="display:none;"><table class="jne-weight-content">' . $this->_tooltip_content . '</table></div>'; } } } }
public function calculate_shipping($package = array()) { global $jne; if ($this->_chosen_city !== false) { $index_kota = $this->_chosen_city; // hitung berat $total_weight = $this->calculate_weight(); // ambil rows data $data = $jne->getRows(); // filter data berdasarkan index kota $filtered = array_filter($data, function ($rows) use($index_kota) { return $rows['index'] == $index_kota; }); if ($kota = array_pop($filtered)) { foreach ($kota['tarif'] as $layanan => $tarif) { // hitung tarif per berat item $cost = $tarif * $total_weight; $rate = array('id' => $this->id . '_' . $layanan, 'label' => sprintf('%s (%s kg x %s)', $this->title . ' ' . strtoupper($layanan), $total_weight, JNE_rupiah($tarif)), 'cost' => $cost); $this->add_rate($rate); } } } }