China Post parcel has registered peace mail, here is the registered national postal parcel. This mode of transport divides the country into 10 districts, each of which corresponds to a different rate (how much per kilogram).
Since there may be different rates for different countries, all implementations of this plugin are not as simple as to show just some basic parameters, the actual national partition rate table needs to be imported into the database, and these zen-cart are not implemented. The workload is a bit large, for example, in order to be able to use the country's corresponding Chinese name Package country import into the partition table, we need to expand the countries table, the Chinese name of each country to correspond up. This step can write a program batch import, here skipped. The next step is to create a partition where the Zen-cart default geo_zone is reused. Table to import:
However, in order for each geo_zone to correspond to the rate, the Geo_zone needs to be extended (add Cost field)
1 |
ALTER TABLE ' geo_zones ' ADD ' cost ' VARCHAR (+) NULL DEFAULT ' 0 ' |
The correspondence of the corresponding country of the partition is established, and the Cost field of each partition is used to record the rate of the partition. Then the quote method of the China Post Freight module:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
Class Methodsfunction quote ($method = ") { global er, $shipping _weight, $shipping _num_ boxes, $db, $currencies; $total _weight = $shipping _weight * $shipping _num_boxes; if ($total _weight > (int) module_shipping_china_post_max_weight) { return false; } / /package weight $total _weight + = (int) module_shipping_china_post_package_weight; $cost = $db->execute ("Select Gz.geo_zone_name, Gz.cost, ztgz.zone_id from Geo_zones GZ, Zones_to_geo_zones ztgz where gz.geo_zone_id = ztgz.geo_zone_id and ztgz.zone_country_id = ". (int) er->delivery[' country ' [' ID ']. "and ztgz.zone_id = 0 and gz.geo_zone_name like ' chinapost_% '"); if ($cost->recordcount () > 0) { $ First = ROund (float) module_shipping_china_post_cost,2); $continue = Round ($cost->fields[' cost '],2); $rate = (float) $currencies- >currencies[' CNY ' [' Value ']; if ($rate <= 0) { $rate = 1; } $disc = (float) MODULE _shipping_china_post_rate; if ($disc <= 0) { $disc = 1; } $ttl = Round ($disc * ($first + $continue *ceil ($total _WEIGHT/10)/100)/$rate, 2); $this Quotes = Array (' id ' = = $this->code, ' module ' = Module_ shipping_china_post_text_title, ' methods ' = = Array ( Array (' id ' = = $this->code, ' title ' = module_shipping_china_post_text_way, ' cost ' $ttl))); }else{ return false; } if ($this->tax_class > 0) { $this->quotes[' tax '] = zen_get_tax_rate ($this->tax_class, er->delivery[' country ' [' ID '], er->delivery[' zone_id ']); } if (Zen_not_null ($this->icon)) $this->quotes[' icon ' ] = Zen_image ($this->icon, $this->title); return $this->quotes;} |
Mainly according to the country code to find out the rate, if there are other modes of transport also adopt a similar method, then a country may correspond to multiple geo_zone, this time need to filter out the Geo_zone in line with the current mode of transport, when the partition table is imported, each partition is used Chinapost_ Prefix, so add the like ' chinapost_% ' condition here to filter out the current mode of transport of the partition, of course, it is important to avoid the same country to load the same mode of transport in different partitions (national partition import need to consider this logic), otherwise you will get multiple rates, This is always used to return the record that is ranked first. Enterprise Templates Web site |