You have to install and configure it, and it will be shown at the frontend under Shipping Methods while performing a checkout.
As you already know, modules or extensions can be created by cloning an existing one that functions in a similar way to what you want. So, for Shipping, we will be cloning any one of them that fulfills our requirement. For example, if you want the shipping cost to be charged as per the total cost purchased, you can clone the weightbased shipping module; likewise, if you want to make DHL shipping rates module using the live rate, look up from the DHL site. You need to start with the existing UPS shipping extension.
Let's start to make the Shipping module that is based on the total cost purchased.
Changes made in the admin folder
In this section we will see the changes that are to be made in the admin folder to create the shipping module:
1. Navigate to admin/controller/shipping/ and copy weight.php and paste it in the same folder. Rename it to totalcost.php, open it in your favorite text editor, and then find the following lines:
class ControllerShippingWeight extends Controller {
Change the class name as follows: class ControllerShippingTotalcost extends Controller {
Now find "weight" and replace all with "totalcost". Then, save the file.
2. Navigate to admin/language/english/shipping and copy weight.php and paste in the same folder and rename it to totalcost.php and open it. Then find "Weight" and replace all with "Total Cost".
After performing the replace, find the following code:
$_['entry_rate'] = 'Rates:<br /><span class= "help">Example: 5:10.00,7:12.00 Total Cost:
Cost, totalcost:Cost, etc..</span>';
Then perform the following changes:
$_['entry_rate'] = 'Total cost:Rates:<br />
<span class="help">Example: 100:10.00,200:20.00
Total Cost:ShippingCost, TotalCost:Shipping Cost, etc.</span>';
3. Navigate to admin/view/template/shipping, copy the weight.tpl file, and paste it in the same folder. Rename it to totalcost.tpl, open it, then find "weight", replace it with "totalcost", and then save it.
Changes made in the catalog folder
After the changes are made in the admin folder, we will now see the changes to be made in the catalog folder to create the shipping module.
1. Go to catalog/model/shipping, copy the weight.php, paste it in the same folder, and rename it tototalcost.php. Open it and find the following line:
class ModelShippingWeight extends Model {
Change the class name as follows: class ModelShippingTotalcost extends Model {
Now find "weight" and replace all with "totalcost". After performing the replacement, find the following lines of code: $totalcost = $this->cart->gettotalcost();
And perform the following changes:
$totalcost = $this->cart->getSubTotal();
Our requirement is to show the shipping cost as per the total cost purchased, so we have performed this change.
Now, find the following lines:
if ((string)$cost != '') {
$quote_data['totalcost_' . $result['geo_zone_id']] = array('code'=>'totalcost.totalcost_' . $result[ 'geo_zone_id'],'title' => $result['name'] . '
(' . $this->language->get('text_totalcost') . '
' . $this->totalcost->format($totalcost, $this-> config->get('config_totalcost_class_id')) . ')',
'cost'=> $cost,
'tax_class_id' => $this->config->get(
'totalcost_tax_class_id'),
'text'=> $this->currency->format($this->tax->calculate(
$cost, $this->config->get('totalcost_tax_class_id'),
$this->config->get('config_tax'))));
}
As we need only the name, change the following line of code:
'title'=> $result['name'] . ' (' . $this->language->get(
'text_totalcost') . '' . $this->totalcost->format(
$totalcost, $this->config->get(
'config_totalcost_class_id')) . ')',
To the following:
'title' => $result['name'],
Weight has different classes such as kilogram, gram, and pound, but in our total cost purchased, we did not have any class specified, so we have removed it.
Now click on Save.
2. Go to catalog/language/english/shipping and copy the weight.php file and paste it in the same folder and rename it to totalcost.php. Open it and find "Weight" and replace it with "Total Cost"
With these changes, the module is ready to be installed. Navigate to Admin | Extensions | Shipping, find Total Cost Based Shipping, click on [Install], provide the permission to modify and access to the user, and then edit to configure it. In the general tab, make a change in the Status field to Enabled. Other tabs are loaded as per the Geo Zone setting. For default, UK Shipping and UK VAT Zoneare set as Geo Zone:
3. Now insert Total cost Rates. If the subtotal reaches 100 and the shipping cost is 20, we have to insert 100:20.
4. If the customer tries to order more than the inserted total cost, shipping is deactivated.
5. In this way, you can now clone the Shipping modules and make the changes on the logics as necessary.
No comments:
Post a Comment