Yeah, I comment all my hacks and label them "HACK" religiously. Then when there is an update, I can search in all the files for case sensitive "HACK" and locate them all.
Didn't mean to put you off, I'll be happy to help you with this one.
First get the first zip from above and install it. (after you back up the necessary files of course).
Let me know if you receive any errors (some of the ones I got, I caused in the process, so you might not get them).
If you get a Call to undefined function: tax_based_on_vendor_address() its because that function isn't in the ps_checkout included in the zip.
HERE IT IS: /**
* If the customer is in the EU then tax should be charged according to the
* vendor's address, and this function will return true.
*/
function tax_based_on_vendor_address () {
global $__tax_based_on_vendor_address;
global $vmLogger;
if (!isset ($__tax_based_on_vendor_address)) {
$__tax_based_on_vendor_address = ps_checkout::_tax_based_on_vendor_address ();
if ($__tax_based_on_vendor_address)
$vmLogger->debug ('calculating tax based on vendor address');
else
$vmLogger->debug ('calculating tax based on shipping address');
}
return $__tax_based_on_vendor_address;
}
function _tax_based_on_vendor_address () {
global $auth;
global $vmLogger;
switch (TAX_MODE) {
case '0':
return false;
case '1':
return true;
case '17749':
if (! array_key_exists ('country', $auth)) {
$vmLogger->debug ('shopper\'s country is not known; defaulting to vendor-based tax');
return true;
}
$vmLogger->debug ('shopper is in ' . $auth['country']);
return ps_checkout::country_in_eu_common_vat_zone ($auth['country']);
default:
$vmLogger->warning ('unknown TAX_MODE "' . TAX_MODE . '"');
return true;
}
}
function country_in_eu_common_vat_zone ($country) {
$eu_countries = array ('AUT', 'BEL', 'CYP', 'CZE', 'DNK', 'EST', 'FIN', 'FRA', 'DEU', 'GRC', 'HUN', 'IRL', 'ITA', 'LVA', 'LTU', 'LUX', 'MLT', 'POL', 'PRT', 'SVK', 'SVN', 'ESP', 'SWE', 'NLD', 'GBR');
return in_array ($country, $eu_countries);
}
paste it in AFTER THE LAST FUNCTION "approx()" which ends around line 2128 and looks like this: /*
* @abstract This function is very useful to round totals with definite decimals.
*
* @param float $value
* @param integer $dec
* @return float
*/
function approx( $value, $dec = 2 ) {
$value += 0.0;
$unit = floor( $value * pow( 10, $dec + 1 ) ) / 10;
$round = round( $unit );
return $round / pow( 10, $dec );
}
AND BEFORE THE CLOSING BRACE AND PHP TAG }
?>
See if you can add new products.
If you get ERROR: Product ID missing
You need to replace the line around 269 in ps_product that reads:
$q .= $d["product_discount_id"] . "','$timestamp','$timestamp','".$d["product_tax_id"]."')";
with:$q .= $d["product_discount_id"] . "','$timestamp','$timestamp','".$d["product_tax_id"]."','".$d["product_taxable"]."')";
These are the 2 major issues I ran into. Let me know if you have any more questions. I'll try to help.
Jeff