Author Topic: ( Help )Indonesia Shipment Method and Drop Down Shipper List Vm1  (Read 1395 times)

xtravaganza

  • Beginner
  • *
  • Posts: 1
  • A beginner
  • Skype Name: xtra.vaganza
Hi, first sorry for my poor English.

I have two issues :

1. I'm using Virtuemart 1.1.4. My online shop only sell products for local customers and doesn't need International shipment rates, and from my experience with VM 1, i know what to do. But because there are many cities with different shipping cost, I have to create lots of shipment methods and add each city to my list. No need to worry, i have enough time to work on it.

The problem is : I can't multiple selected shipment methods , I already have 50++ cities .

2. Because i have more than 50 cities in my list, my Select Shipment page has long list radio button. I want to know how to create drop down list for Shippers to make my page prettier.

Before : Example I have long list of city shipping cost


After : I can choose a city shipping cost from a drop down menu


Code: [Select]
<?php
defined
('_VALID_MOS') or die('Direct Access to this location is not allowed.');
class 
JNE {
  var 
$debug     0;
  var 
$classname "JNE";
  function 
list_rates( &$d ) {
    global 
$database$CURRENCY_DISPLAY$cart;
    
$u =& new ps_DB;
    
$u->query("SELECT * FROM #__{vm}_user_info, #__{vm}_country WHERE user_info_id='".$d["ship_to_info_id"]."' AND (country=country_2_code OR country=country_3_code)");
    
$u->next_record(); $u $u->record[0];
    echo 
"<table border=1 cellpadding=1 cellspacing=0 width=100%> \n";
    if( 
== ){ 
      
$dbc = new ps_DB;
      
$dbc->query("SELECT country,zip FROM #__{vm}_user_info WHERE user_info_id='".mosGetParam($_REQUEST'ship_to_info_id')."'");
      
$dbc->next_record();
      
$zip     $dbc->f("zip");
      
$country $dbc->f("country");
      
$dbr = new ps_DB;
      
$q 'SELECT sc.*, sr.* FROM #__{vm}_shipping_carrier AS sc '
         
'LEFT JOIN #__{vm}_shipping_rate AS sr ON sr.shipping_rate_carrier_id = sc.shipping_carrier_id '
         
"WHERE (sr.shipping_rate_country LIKE '%" $country "%' OR sr.shipping_rate_country = '') AND "
         
. ( is_numeric($zip)
              ? 
"(sr.shipping_rate_zip_start <= '" $zip "' OR  LENGTH(sr.shipping_rate_zip_start) = 0 ) AND (sr.shipping_rate_zip_end >= '" $zip "' OR  LENGTH(sr.shipping_rate_zip_end) = 0 ) AND "
              
''
           
)
         . 
"(sr.shipping_rate_weight_start <= '" $d["weight"] . "' AND sr.shipping_rate_weight_end >= '" $d["weight"] . "') "
         
'ORDER BY sc.shipping_carrier_list_order ASC, sr.shipping_rate_list_order ASC, sr.shipping_rate_name';
      
$dbc->query($q);
      
$selected_rate_id = (array_key_exists('shipping_rate_id',$d) ? $d["shipping_rate_id"] : null);
      
$first = ($selected_rate_id );
      while (
$dbc->next_record()) {
        
$shipping_total   $this->get_shipping_total$d$dbc->record[$dbc->row] );
        
$shipping_rate_id $this->classname.'|'.$dbc->f('shipping_carrier_name').'|'.$dbc->f('shipping_rate_name').'|'.$shipping_total;
        if(
$first || ($selected_rate_id == $shipping_rate_id))
          
$checked 'checked=true';
        else
          
$checked '';
        
$shipping_rate_id urlencode($shipping_rate_id);

        echo 
"<tr>";
        echo 
'<td><input type=radio name=shipping_rate_id id=weight_shipping_rate '.$checked.' value="'.$shipping_rate_id.'" /></td>';
        echo 
'<td nowrap width=75%><img align="middle" src="http://localhost/gayamodeolshop/images/jne.png"  alt="logo" /><label for=weight_shipping_rate>'.$dbc->f('shipping_carrier_name').' '.$dbc->f('shipping_rate_name').'</label></td>';
        echo 
'<td align=right width=100%>'.$CURRENCY_DISPLAY->getFullValue($shipping_total).'</td>';
        echo 
"</tr>\n";
        
$_SESSION[$shipping_rate_id] = $dbc->f('shipping_rate_id');
        
$first 0;
      }
    } else {
    }
    echo 
"</table> \n";
    if( 
$this->debug )
      
$this->print_debug$d$u );
    return 
true;
  }
  function 
get_shipping_total( &$d$s null ) {
    global 
$total$tax_total;
    require(
CLASSPATH ."shipping/".$this->classname.".cfg.php");


    if ( 
$_SESSION['auth']['show_price_including_tax'] != ) {
      
$taxrate 1;
      
$order_total $total $tax_total;
    } else {
      
$taxrate $this->get_tax_rate() + 1;
      
$order_total $total;
    }
    if( 
$s ){
      
$algoritma_pengiriman $WEIGHT_CONFIG['WEIGHT_SHIPPER_ALG'];
      if( 
$d["weight"] < 
        
$algoritma_pengiriman '(shipping_rate_package_fee + shipping_rate_value)';
    } else {
      
$algoritma_pengiriman $WEIGHT_CONFIG['WEIGHT_SHIPPER_ALG'];
      if( 
$d["weight"] > 
        
$algoritma_pengiriman '(shipping_rate_package_fee + (weight * shipping_rate_value))';
    }
    foreach( 
$d AS $k => $v )
      if( !
is_array$v ) )
        
$algoritma_pengiriman preg_replace('/'.$k.'/',$v,$algoritma_pengiriman);
    if( 
$s != null )
      foreach( 
$s AS $k => $v )
        if( !
is_array$v ) )
          
$algoritma_pengiriman preg_replace('/'.$k.'/',$v,$algoritma_pengiriman);
    if( !eval( 
'return $shipping_total='.$algoritma_pengiriman.';' ) )
      echo 
'<div class=alert>ERROR - Config ['.$this->config_name.'] Algorithm ['.$algoritma_pengiriman.']</div>';
    
$shipping_total $shipping_total $taxrate;
    if( 
$this->debug ){
      echo 
"-- Shipping -------------------------------<br/>";
      echo 
'$shipping_total = '.$algoritma_pengiriman."<br/>";
      echo 
'Shipping Total: '.$shipping_total."<br/>";
      foreach( 
$s AS $k => $v ) echo "$k => $v<br/>";
      echo 
"<br/>";
    }
    return 
$shipping_total;
  } 
  function 
get_rate( &$d ) {
    
$shipping_rate_id $d["shipping_rate_id"];
    
$is_arr explode("|"urldecode(urldecode($shipping_rate_id)) );
    
$order_shipping $is_arr[3];
    return 
$order_shipping;
  }
  function 
get_tax_rate() {
  }
  function 
validate$d ) {
    
$shipping_rate_id $d["shipping_rate_id"];
    if( 
array_key_exists$shipping_rate_id$_SESSION ) )
      return 
true;
    else
      return 
false;
  }
function show_configuration() {
return true ;
}

?>


or focus code
Code: [Select]
        $shipping_rate_id = urlencode($shipping_rate_id);

        echo "<tr>";
        echo '<td><input type=radio name=shipping_rate_id id=weight_shipping_rate '.$checked.' value="'.$shipping_rate_id.'" /></td>';
        echo '<td nowrap width=75%><img align="middle" src="http://localhost/gayamodeolshop/images/jne.png"  alt="logo" /><label for=weight_shipping_rate>'.$dbc->f('shipping_carrier_name').' '.$dbc->f('shipping_rate_name').'</label></td>';
        echo '<td align=right width=100%>'.$CURRENCY_DISPLAY->getFullValue($shipping_total).'</td>';
        echo "</tr>\n";
        $_SESSION[$shipping_rate_id] = $dbc->f('shipping_rate_id');
        $first = 0;
      }
    } else {
    }
    echo "</table> \n";
    if( $this->debug )
      $this->print_debug( $d, $u );
    return true;
  }

But i'm still not satisfied because i can't see the price in the drop down menu. Last thing, i want the cities sorted in alphabetical order. Anybody can help me?

Thanks.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9092
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: ( Help )Indonesia Shipment Method and Drop Down Shipper List Vm1
« Reply #1 on: November 26, 2015, 16:51:48 pm »
I moved it to the general forum. All other vm1.1 boards are closed.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/