I need someone to help write a line of PHP code for my opencart shipping module.
A section of the shipping module PHP file is below.
Fastway and A-national are both courier companies.
Currently the script does this: All products will be shipped with fastway courier. However If the item is over 25kg and over 100cm, then it will be shipped with A-national.
What i need to do is simply add a line of code which makes all products from a certain manufacture to always use the A-national courier. There is a manufacturer field inside opencart and all products under this manufacturer will have to use the A-national courier.
A-National Courier shipping quote is using this calculation, you can see in script.
$calprice=$baseprice+$weight*$perkilo;
$calfuel=($calprice*16.9/100)+$calprice;
$calfuel=$calfuel+($calfuel*0.1);
Its a pretty quick and straight forward job i think and it will be easy for someone who knows PHP very well and some familiarity with opencart.
------------------------------------------------------------------------
class ModelShippingFastway extends Model {
function getQuote($address) {
$lengths=$this->cart->getProducts();
$ll=0;
foreach ($lengths as $length){
if ($length['length']>=100) {$ll=$ll+1;}
}
$query=$this->db->query('select * from expresspost where postcode="'.$address['postcode'].'" ');
// if ( ($ll > 0 || $this->cart->getWeight() >25) || ($this->cart->getWeight() >25) && $query->row['status']==0 ) {
if ( !empty($query->row) && $ll > 0 && $query->row['status']==1 || $this->cart->getWeight() >25 ) {
$zone=$this->db->query("select * from expresszone where zone='".$query->row['zone']."'");
$weight = intval($this->weight->convert($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->config->get('fastway_weight_class_id')));
$baseprice=$zone->row['baseprice'];
$perkilo=$zone->row['perkilo'];
$minprice=$zone->row['minprice'];
$calprice=$baseprice+$weight*$perkilo;
$calfuel=($calprice*16.9/100)+$calprice;
$calfuel=$calfuel+($calfuel*0.1);
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('flat_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if (!$this->config->get('flat_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
$method_data = array();
if ($status) {
$quote_data = array();
$quote_data['fastway'] = array(
'code' => '[login to view URL]',
'title' => "A - National Courier",
'cost' => $calfuel,
'tax_class_id' => $this->config->get('flat_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($calfuel, $this->config->get('flat_tax_class_id'), $this->config->get('config_tax')))
);
$method_data = array(
'code' => 'fastway',
'title' => "A - National Courier",
'quote' => $quote_data,
'sort_order' => $this->config->get('fastway_sort_order'),
'error' => false
);
}
return $method_data;
} else {
$this->load->language('shipping/fastway');
Hi,
I am Opencart expert and I have worked for you earlier. I can do this job. So you need if any product belongs to specified manufacturer, then regardless of cart weight it will use A-national courier?
Thanks
Harsh
$34 AUD trong 1 ngày
4,9 (629 nhận xét)
8,3
8,3
20 freelancer chào giá trung bình $42 AUD cho công việc này
Dear Sir, We claim to get it done perfectly for you EXACTLY in the way you want it - Kindly give we a chance and we will prove myself - Ready to prove our words,
let's get it done right away and I mean RIGHT AWAY !! Looking forward to hear from you soon - GOD Bless You.
hi
we could do it perfectly with accuracy,
please let us know if you want any clarification.
if you want us to share our skill and previous work
please initiate the chat..
Check my feedback... I'm expert in opencart. Let me know if you want me to do this...............................................................................................................
I am Eugene. Have been working on lot of PHP web applications for the past 4 years.
How I plan to complete the task:
Precondition: I need to have information of the manufacturer either manufacturer id or the name.
TODO: (changes on the model)
- Loop through all the products for checkout by the user in opencart.
- Separate those products from the manufacturer to those which should use the A-national courier and those which are not.
- Calculate for both separated products the $calprice and $calfuel.
- Calculate the sum of both calculated $calprice and $calfuel.
- Set the method code of method_data to be 'fastway-national' to indicate that it will be shipped using both courier and return the method array.
On checkout:
- Add the code to check if the method is 'fastway-national', and create 2 order each with its own shipping details.