1

Can't get this ocmod to work. I even paid someone to get this to work but I'm beginning to think he doesn't know as much about opencart/php as he says.

Parse error: syntax error, unexpected '{', expecting '(' in public_html/vqmod/vqcache/vq2-system_modification_catalog_controller_product_product.php on line 367

Line 365-368 this is the code:

    $you_save = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')) - $this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
    if ($product_info['price'] == 0) { $you_save_or = 0; } 
    else if { $you_save_or = round((($product_info['price'] - $discount['price']) / $product_info['price'] * 100)); } else
    {  $text_you_discount = round($product_info['price'] - ($product_info['price']* 0.15));}

Here is the part of the ocmod/vqmod file that I'm editing but can't get it to work:

        <operation>
            <search><![CDATA[
            $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
            ]]></search>
            <add position="after"><![CDATA[
            $data['you_save'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')) - $this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
            $data['you_save_or'] = round((($product_info['price'] - $product_info['special']) / $product_info['price'] * 100));
            $data['text_you_discount'] = round($product_info['price'] - ($product_info['price']* 0.15));
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[
            foreach ($discounts as $discount) {
            ]]></search>
            <add position="after"><![CDATA[
            $you_save = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')) - $this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
            if ($product_info['price'] == 0) { $you_save_or = 0; } 
            else if { $you_save_or = round((($product_info['price'] - $discount['price']) / $product_info['price'] * 100)); } else
            {  $text_you_discount = round($product_info['price'] - ($product_info['price']* 0.15));}
            ]]></add>
        </operation>
J-T
  • 9
  • 5
  • I don't have any experience with opencart or this OCmod/VQmod but this is fail of PHP basics. If you have an `else if` there should be some condition after it enclosed with parentheses not braces. – TheDrot Sep 21 '16 at 04:45
  • So how would you fix this code above? – J-T Sep 21 '16 at 05:21
  • Change this `round((($product_info['price'] - $discount['price']) / $product_info['price'] * 100));` with `round(($product_info['price'] - $product_info['special']) / ($product_info['price'] * 100));` in your OCmod/vQmod. – kanenas Sep 21 '16 at 12:38

0 Answers0