I've got a feed where the prices don't include VAT, but in order for it to match the other merchants where VAT is included I want to add 17.5% to the prices on that one merchant.
Just wondering if there is a simple bit of code I could add to the import process to add the 17.5% where merchant="x" ?
Thanks
Phillip
That works a treat David ;-)
Many thanks
Phillip
Sat nav Price Comparison
This simply doesn't do anything for me. Has anything changed in the newer distributions. Should it still work?
Is "Example Merchant" supposed to be the feed name (merchant.txt) or the name i give the merchant on import? Is lower/uppercase an issue? (i did try it all i think)
Kind Regards,
Anders
Hello Anders,
"Example Merchant" is the merchant name exactly as entered on Feed Registration (Step 2). The code is certainly still valid, so if you're not seeing any effect feel free to email me any files you have modified and i'll check them over for you...
Cheers,
David.
It works now. I wasn't thinking straight before. Sorry.
Regards
Di David,
i cant find this line in the current version, has this changed?
regards
Phil Stone
www.buy24-7.net
Hi Phil,
In the latest distribution, look for the following code starting at line 274
/* decimalise price */
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
...and REPLACE with:
/* decimalise price */
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
if ($admin_importFeed["merchant"] == "Example Merchant")
{
// add VAT at 17.5% (multiply by 1.175)
$importRecord["price"] =
$importRecord["price"] * 1.175;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}
Cheers,
David.
Hello David,
How do I add VAT to more than one merchant. I have a feed with mixed VAT included and excluded.
thanks,
Bryan
Hi Bryan,
In the latest distribution, instead of placing the modification where described above, look for the following code at line 292 of includes/admin.php:
if (!$merchant) return;
...and at that point add the following:
if (
($merchant == "Example Merchant")
||
($merchant == "Another Example Merchant")
)
{
// add VAT at 17.5% (multiply by 1.175)
$importRecord["price"] =
$importRecord["price"] * 1.175;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hello David,
It works! Thank you.
If there is more than 2 merchant I guess I just have to change it to:
if (
($merchant == "Example Merchant")
||
($merchant == "Another Example Merchant")
||
($merchant == "Another Example1 Merchant")
)
{
// add VAT at 17.5% (multiply by 1.175)
$importRecord["price"] =
$importRecord["price"] * 1.175;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}
Hi Richard - that's exactly right...
Cheers,
David.
--
PriceTapestry.com
Hello David,
when is it possible, please write me new manual for include this noVAT prices in new Distribution 12/10A. Many Thanks! :)
Hi,
In the 12/10A beta, look for the following code at line 297:
if (!$importRecord["merchant"]) return;
...and for the multi-merchant verison, REPLACE that with:
if (!$importRecord["merchant"]) return;
if (
($importRecord["merchant"] == "Example Merchant")
||
($importRecord["merchant"] == "Another Example Merchant")
||
($importRecord["merchant"] == "Another Example1 Merchant")
)
{
// add VAT at 17.5% (multiply by 1.175)
$importRecord["price"] =
$importRecord["price"] * 1.175;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}
Cheers,
David.
--
PriceTapestry.com
Hi David,
Thanks for quick reply. With your code i have this error: Notice: Undefined index: merchant ... i change code to:
if (!$importRecord["merchant"]) return;
if (
($importRecord["merchant"] == "Example Merchant")
||
($importRecord["merchant"] == "Another Example Merchant")
||
($importRecord["merchant"] == "Another Example1 Merchant")
)
{
// add VAT at 17.5% (multiply by 1.175)
$importRecord["price"] =
$importRecord["price"] * 1.175;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}
and script working. It is this change OK?
Hi,
That's spot on! I've corrected the code above also...
Cheers,
David.
--
PriceTapestry.com
Hi David
I have just implemented this and it looks like admin.php has changed slightly in the latest revision: 12/10B
I also only needed it for one merchant and also changed the vat rate to 20% - so now I have on line 342:
if (!$importRecord["merchant"]) return;
if ($importRecord["merchant"] == "Merchant Name")
{
// add VAT at 20% (multiply by 1.20)
$importRecord["price"] =
$importRecord["price"] * 1.20;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}
It seems to work fine but thought I'd double check?
Cheers
Darren
Looks fine Darren!
Cheers,
David.
--
PriceTapestry.com
Hi. Is it possible to have a filter for VAT?
Hi,
Sure - here's code for an Add Tax filter - add to includes/filter.php:
/*************************************************/
/* addTax */
/*************************************************/
$filter_names["addTax"] = "Add Tax";
function filter_addTaxConfigure($filter_data)
{
widget_textBox("Rate (%)","rate",TRUE,$filter_data["rate"],"",3);
}
function filter_addTaxValidate($filter_data)
{
if (!$filter_data["rate"])
{
widget_errorSet("rate","required field");
}
}
function filter_addTaxExec($filter_data,$text)
{
$text = ($text / 100) * (100 + $filter_data["rate"]);
return tapestry_decimalise($text);
}
Cheers,
David.
--
PriceTapestry.com
Hi Phillip,
Yes - that should be reasonably straight forward.
In includes/admin.php you will find the following code (line 166 in the distribution):
$record[$admin_importFeed["field_price"]] =
tapestry_decimalise($record[$admin_importFeed["field_price"]]);
To do what you want, try the following immediately afterwards:
if ($admin_importFeed["merchant"] == "Example Merchant")
{
// add VAT at 17.5% (multiply by 1.175)
$record[$admin_importFeed["field_price"]] =
$record[$admin_importFeed["field_price"]] * 1.175;
// decimalise again to round to 2 decimal places
$record[$admin_importFeed["field_price"]] =
tapestry_decimalise($record[$admin_importFeed["field_price"]]);
}
That should do the trick!
Cheers,
David.