I've added a shipping method called Saturday Delivery, which as the name suggests, allows customers to pay a premium to have goods delivered on a Saturday.
What's the easiest way to only show this shipping method on a Friday? I'm guessing a simple VQMOD to look at the current day and if t's a Friday then show this method. If not, hide it.
Which files do I need to modify to achieve this?
OK, this was a pretty simple fix in the end and here's what I did.
My postage methods are all weight-based shipping options. Each shipping method is its own Geo Zone so I can determine which regions accept which shipping method.
The file you need to modify is: catalog/model/extension/shipping/weight.php
By default it lists all geo zone by running the following query:
My new geo zone has a geo_zone_id of 11 so I needed to modify the query on a Friday so that it queries for all geo zone except mine with id 11.
To check the current day simply use the PHP Date command.
Below is the final VQMOD entry.
My postage methods are all weight-based shipping options. Each shipping method is its own Geo Zone so I can determine which regions accept which shipping method.
The file you need to modify is: catalog/model/extension/shipping/weight.php
By default it lists all geo zone by running the following query:
Code: Select all
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name");
Code: Select all
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone WHERE geo_zone_id <> 11 ORDER BY name");
Code: Select all
//The D switch gets the first three letters of the current daye
$current_day = day("D");
if ($current_day == "Fri")
{
}
Code: Select all
<!--Only Show Saturday Delivery on a Friday-->
<file name="catalog/model/extension/shipping/weight.php">
<operation info="Only show the Saturday Delivery Option if the current day is a friday.">
<search position="replace"><![CDATA[
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name");
]]></search>
<add><![CDATA[
$current_day = date("D");
if ($current_day == "Fri")
{
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name");
}
else
{
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone WHERE geo_zone_id <> 11 ORDER BY name");
}
]]></add>
</operation>
</file>
[/code[
Who is online
Users browsing this forum: No registered users and 4 guests