Military Discount
Military Discount is a Zen Cart™ discounting module which allows you
to offer reduced prices for orders that are shipped to APO/FPO addresses.
Donate! Show your appreciation by
supporting my efforts.
Relevance: Zen Cart™ 1.3.0 - 1.3.9, 1.5.x
Current Version: 1.1
Support Thread: Military Discount Support Thread
Cost: Free, but
donation appreciated
Location: Zen Cart Downloads page, under Pricing Tools.
Download: Military Discount on Zen Cart Downloads Page
Overview:
Military Discount allows you to offer a discount (percentage
or fixed amount) for shipments headed to an APO or FPO.
Military Discount is an order total module; it only shows up
on the second page of checkout.
Payment Page displaying Military Discount
Installation Instructions:
- Back up everything! Try this in a test environment prior to installing
it on a live shop.
- Copy the contents of the unzipped folder to the root directory of your
shop.
- Login to admin and in Modules->Order Total you will see 'Military Discount' listed along with all the other modules available.
- Click on 'Military Discount' to highlight the module and click on 'Install'
- Set the parameters according to your discounting plan.
- If you wish, follow the guidelines in marketing
to advertise your discounts.
Marketing
A discounting plan reaches maximum effectiveness through advertising.
Customize the tpl_product_info_display.php file to advertise
your discounts. Put the file
includes/templates/template_default/templates/tpl_product_info_display.php
into includes/templates/<Your Template>/templates, and add this block
of code to the page:
<?php
$value = "ot_military_discount.php";
include_once(zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] .
'/modules/order_total/', $value, 'false'));
include_once(DIR_WS_MODULES . "order_total/" . $value);
$discount = new ot_military_discount();
echo '<div class="content" id="militaryDiscountPolicy">';
$resp = $discount->get_html_policy();
echo $resp;
echo '</div>';
echo '<br class="clearBoth" />';
?>
The placement of this code is a matter of personal preference;
try placing it below the product description and adjust to your tastes.
Notes for on Taxes
(If you don't use embedded taxes, and don't have a mix of
taxable and tax-free products, and don't have a different rate of tax
for shipping,
please skip this section.)
Mixing taxable and non-taxable products
The way taxes are handled internally in Zen Cart 1.x is that the entire tax amount is stored in the cart; the tax is not broken down on an item by item basis. For this reason, tax recalculation after discounting may not work perfectly if items which attract different levels of tax are in the cart - for example, taxable and non-taxable items. This issue is discussed in
this forum post, and we are hopeful that Zen Cart 2.x will solve this problem.
Included Taxes and My Mods
This section is only relevant to Zen Carts which
use "Display Prices with Tax" = true (in Admin->Configuration->My Store).
If your shop displays prices with tax included,
you should configure my discounting mods to use Include Tax = true
and set Re-Calculate tax to either "Standard" or "VAT" (depending on
how taxes are handled in your jurisdiction).
There was a time when my software would gross up percentage discounts
for tax but not currency based discounts.
I decided to change this
and handle both uniformly, so now (post April 2010) if you
configure one of my discount mods to use include taxes = true,
your discount will be grossed up whether it is a currency value
or a percentage.
Tax Descriptions
Due to the way gross-up and gross-down calculations are done for
shops using embedded taxes, your tax descriptions (as shown in
Admin->Locations/Taxes->Tax Rates) must be unique.
The customer using the setup shown below had problems because
the recalculation logic couldn't tell which version of Varav moms
(Swedish for "Including VAT") should be used.
Different rates of tax for shipping
If you have taxable shipping but the tax rate is different than it is for
products, you'll need to make some code changes. Firstly, be sure your
descriptions for shipping taxes include an easily identifiable string
such as "on shipping"
Then, in the discount module you use, skip over this tax when computing
the updated amount of tax.
Here is a block of logic from Quantity Discounts 1.11. (Newer versions
may look different.)
switch ($this->calculate_tax) {
case 'Standard':
reset($order->info['tax_groups']);
while (list($key, $value) = each($order->info['tax_groups']))
{
if (strpos($key,"on shipping") !== false) {
continue;
}
$tax_rate = zen_get_tax_rate_from_desc($key);
if ($tax_rate > 0) {
$od_amount[$key] = $tod_amount = round((($od_amount['total'] * $tax_rate)) /100, 2) ;
$od_amount['tax'] += $tod_amount;
}
}
break;
Here is a block of logic from Big Chooser 1.2.16. (Newer versions
may look different.)
switch ($this->calculate_tax) {
case 'Standard':
reset($order->info['tax_groups']);
$taxGroups = array_keys($order->info['tax_groups']);
foreach ($taxGroups as $key )
{
if (strpos($key,"on shipping") !== false) {
continue;
}
$tax_rate = zen_get_tax_rate_from_desc($key);
if ($tax_rate > 0) {
$od_amount[$key] = $tod_amount = round((($taxable_amount * $tax_rate)) /100, 2) ;
$od_amount['tax'] += $tod_amount;
}
}
break;
Files
(new)includes/languages/english/modules/order_total/ot_military_discount.php
(new)includes/modules/order_total/ot_military_discount.php
How do US Military Addresses work?
US Military addresses are formed in such a way as to make them
resemble regular domestic addresses.
Instead of a city and state value, however, they use
the following system:
- In lieu of a city name, the values "APO" (Army
Post Office) or "FPO" (Fleet Post Office)
- In lieu of a state name, the values
- AF (Armed Forces Africa)
- AA (Armed Forces Americas)
- AC (Armed Forces Canada)
- AE (Armed Forces Europe)
- AM (Armed Forces Middle East)
- AP (Armed Forces Pacific)
The country value is always "United States."
The city and state values required for shipping to US military addresses
are part of the stock Zen Cart installation; no additional work is required
on your part.
An example of a proper US Military address is
PFC Gomer Pyle
CMR 123, Box 90210
APO AE 09250
I'm from the United Kingdom - how do I extend this for British Forces abroad?
Put the file includes/languages/english/checkout_shipping.php in your
template (i.e. If your template is called "custom," copy it to
includes/languages/english/custom/checkout_shipping.php).
Change the define TEXT_CHOOSE_SHIPPING_DESTINATION in this
file to include a
statement like:
'If you are shipping to a BFPO, please be sure to
specify "BFPOxxxx" in the Post/Zip Code field.'
Edit the file
includes/modules/order_total/ot_military_discount.php
and change
function is_soldier() {
global $order;
to
function is_soldier() {
global $order;
// UK
$test1 = strpos(strtoupper($order->delivery['postcode']), "BFPO");
$test2 = strpos(strtoupper($order->delivery['suburb']), "BFPO");
if ( !($test1 === false) || !($test2 === false) ) {
return true;
}
...
See
this page
for more information on BFPO shipping rules.
I'm from Canada - how do I extend this for Canadian Forces abroad?
Put the file includes/languages/english/checkout_shipping.php in your
template (i.e. If your template is called "custom," copy it to
includes/languages/english/custom/checkout_shipping.php).
Change the define TEXT_CHOOSE_SHIPPING_DESTINATION in this
file to include a
statement like:
'If you are shipping to a Canadian Forces personnel, please be sure to
specify "STN FORCES" in one of the address fields.'
Edit the file
includes/modules/order_total/ot_military_discount.php
and change
function is_soldier() {
global $order;
to
function is_soldier() {
global $order;
// Canada
$test1 = strpos(strtoupper($order->delivery['street_address']), "STN FORCES");
$test2 = strpos(strtoupper($order->delivery['suburb']), "STN FORCES");
if ( !($test1 === false) || !($test2 === false) ) {
return true;
}
...
Zen Cart only supports two address lines, so you will need to
put the section/mess number and the name of the ship/unit
together on line two (normally they would be on separate lines).
For example:
SGT. JEFF SMITH
MESS #3 HMCS CALGARY FMO VICTORIA
PO BOX 17000 STN FORCES
VICTORIA BC V9A 7N2
CANADA
SGT. JOHN JONES
SECTION 37, KABUL 100
PO BOX 5113 STN FORCES
BELLEVILLE ON K8N 5W6
CANADA
See
this page
for more information on Canadian Forces Shipping rules.
I'm from Italy...
function is_soldier() {
global $order;
// Canada
$test1 = strpos(strtoupper($order->delivery['street_address']), "CASERMA");
$test2 = strpos(strtoupper($order->delivery['suburb']), "CASERMA");
if ( !($test1 === false) || !($test2 === false) ) {
return true;
}
...
I'm from Australia ...
function is_soldier() {
global $order;
// AUS
$email_parts = split('@', $order->customer['email_address']);
$domain = trim($email_parts[1]);
if ($domain == "defence.gov.au") return true;
if ($domain == "navy.gov.au") return true;
// deal with subdomains too
$pos = strpos($domain, "defence.gov.au");
if ($pos !== false) return true;
$pos = strpos($domain, "navy.gov.au");
if ($pos !== false) return true;
...
That Software Guy, Inc.
supports the USO and encourages all Americans to do
likewise
... until every one comes home.
Faces of the Fallen -
take a moment to read their names.
| Certificates of appreciation most welcome! |
|
|
If the information you learned reading this site is helping your store make
more money, please consider making a donation. Thank you!
|
Want more Zen Cart?
Tips and Tricks
Contributions
Extensions
Custom Software
Newsletter