Ben's Pro Tips

Tech Tips Made Easy

March 25, 2014 eCommerce, PHP Tips

OpenCart: How to exclude tax from your Google Products feed

Due to an odd design decision, OpenCart will always factor in sales (or VAT) taxes in your Google Products feed (or Froogle or Google Base or Google Shopping or Google Merchants or whatever the heck they’re calling it this week). This seems to happen regardless of your admin tax settings. This causes your prices to appear inflated as Google expects the base price of the product and adds in tax on its own.

The fix for this is simple. Edit your /catalog/controller/feed/google_base.php file and find the following block:

if ((float)$product['special']) {
    $output .= '<g:price>' . $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id']), $currency_code, $currency_value, false) . '</g:price>';
} else {
    $output .= '<g:price>' . $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id']), $currency_code, $currency_value, false) . '</g:price>';

Change it to:

if ((float)$product['special']) {
    $output .= '<g:price>' . $this->currency->format($product['special'], $currency_code, $currency_value, false) . '</g:price>';
} else {
    $output .= '<g:price>' . $this->currency->format($product['price'], $currency_code, $currency_value, false) . '</g:price>';


You’re all set!

Leave a comment

Time limit is exhausted. Please reload the CAPTCHA.