Jump to content

modelspecialist

Members
  • Content count

    10
  • Joined

  • Last visited

1 Follower

Profile Information

  • Real Name
    Steven
  1. modelspecialist

    Adding a Flat shipping rate outside of my own country

    Hey Mike, I've created a flat rate module for my own webstore just last week. this is for version 2.3.1, but should work with any version really. I have limited php knowledge as well, but with some logic you can manage to create your own shipping modules based on the standard ones. Here's what I did: in the folder includes/modules/shipping, find the 'flat.php' file. copy this to a separate folder to your computer when you open this up, you'll see the following code at the top: class flat { var $code, $title, $description, $icon, $enabled; // class constructor function flat() { global $order; $this->code = 'flat'; $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); Now, this may look very difficult to understand, and it probably is. But let's look passed the code and look at what is on the screen. I see alot of lines with recurring words; I see the word 'flat' and then 'MODULE_SHIPPING_FLAT' come back quite alot. When I scroll down in the php file, I see these exact words coming back frequently.. These are indicators for the code to identify functions and the name of the module. I started off by noting down how I would call my module. Instead of 'Flat Rate', I wanted to call it 'Flat Rate Inside of Europe', so in short, 'flateurope'. I changed the word 'flat' in the code to 'flateurope' and the words 'MODULE_SHIPPING_FLAT' TO 'MODULE_SHIPPING_FLATEUROPE'. In the code somewhere down the line there is the following; 'Do you want to offer flat rate shipping?' I changed this to 'Do you want to offer flat rate shipping inside Europe?' You should do this for the entire file. Using wordpad and the replace function, this will go fairly quickly. I end up with a file which has this code at the top: class flateurope { var $code, $title, $description, $icon, $enabled; // class constructor function flateurope() { global $order; $this->code = 'flateurope'; $this->title = MODULE_SHIPPING_FLATEUROPE_TEXT_TITLE; $this->description = MODULE_SHIPPING_FLATEUROPE_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_FLATEUROPE_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_FLATEUROPE_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_FLATEUROPE_STATUS == 'True') ? true : false); If you take a step back, I simply made a copy of the module, but I changed the references from flat to flateurope. I saved this as flateurope.php. Now, step 2: the language file. In the folder includes/languages/english/modules there is also a file called flat.php. The code in this one is shorter though; define('MODULE_SHIPPING_FLAT_TEXT_TITLE', 'Shipment Fee'); define('MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION', 'Shipment Fee'); define('MODULE_SHIPPING_FLAT_TEXT_WAY', 'Shipment Fee'); Wait a minute.. all those 'MODULE_SHIPPING_FLAT' references are in this file as well - this means that the file we edited earlier, refered to this file to fill in some gaps that are language dependent. Again, change the 'MODULE_SHIPPING_FLAT' words to 'MODULE_SHIPPING_FLATEUROPE'. Now, you save this also as flateurope.php and place it in the language subfolder. We're all done! Now all you need to do is install this flateurope module in your shop and apply a zone to it. Hope that helped.
×