Post by scruft » Sun Dec 09, 2012 1:18 pm

Hi, I'm modifying the vQmod for my theme and I've run into an issue with the placement of some variables. I'm not a PHP expert, so I gather that there's just a simple syntax issue here but I can't figure out where it is.. could someone please have a look for me? Thx :)

The file is controller/module/latest.php, the code added is at lines 89, 90, 96, 97 (stock_status and stock_qty). I've tried clearing the cache but it's still saying I'm trying to call an undefined variable. FYI the code here is from the cache, which I'm using so I can see the final result of the file that the site is trying to use.

Code: Select all

<?php
class ControllerModuleLatest extends Controller {
	protected function index($setting) {
		$this->language->load('module/latest');
		
      	$this->data['heading_title'] = $this->language->get('heading_title');
		
		$this->data['button_cart'] = $this->language->get('button_cart');
				
		$this->load->model('catalog/product');
        
		$this->load->model('catalog/category');
        
        $this->data['categories'] = $this->model_catalog_category->getCategories(0);

		$this->load->model('tool/image');
		
		$this->data['products'] = array();
        if (!isset($setting["filter_name"])) $setting["filter_name"] = '';
        if (!isset($setting["filter_tag"])) $setting["filter_tag"] = '';
        if (!isset($setting["filter_description"])) $setting["filter_description"] = '';
        if (!isset($setting["filter_sub_category"])) $setting["filter_sub_category"] = '';
        if (!isset($setting["filter_manufacturer_id"])) $setting["filter_manufacturer_id"] = '';
        if (!isset($setting["sort"])) $setting["sort"] = 'p.date_added';
        if (!isset($setting["order"])) $setting["order"] = 'DESC';
		$data = array(
            'filter_name'         => $setting["filter_name"], 
			'filter_tag'          => $setting["filter_tag"], 
			'filter_description'  => $setting["filter_description"],
			'filter_sub_category' => $setting["filter_sub_category"], 
            'filter_manufacturer_id' => $setting["filter_manufacturer_id"],
			'sort'  => $setting["sort"],
			'order' => $setting["order"],
			'start' => $setting['start'],
            'limit' => $setting['limit'],
            'filter_category_id' => $setting['category']
		);

        if (isset($setting["special"]) && $setting["special"] == 1) $results = $this->model_catalog_product->getProductSpecials($data); else $results = $this->model_catalog_product->getProducts($data);
    	
		foreach ($results as $result) {

			if ($result['image']) {
                $pageURL = "image/";
                if (file_exists($pageURL.$result['image'])) {
                    $imgsize = (getimagesize($pageURL.$result['image']));
				    $image = $this->model_tool_image->resize($result['image'], $setting['image_width'], ($imgsize[1]/($imgsize[0]/$setting['image_width'])));
                } else $image= false;
			} else {
				$image = false;
			}
						
			if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
				$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$price = false;
			}
					
			if ((float)$result['special']) {
				$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$special = false;
			}
			
			if ($this->config->get('config_review_status')) {
				$rating = $result['rating'];
			} else {
				$rating = false;
			}
            
            $this->data['catprod'] = array();

            $product_category = $this->model_catalog_product->getCategories($result['product_id']);

            foreach ($product_category as $prodcat) {
            
            $category_info = $this->model_catalog_category->getCategory($prodcat['category_id']);
            
            if ($category_info) {
            
            $this->data['catprod'][] = array(
            'name' => $category_info['name'],
            'href' => $this->url->link('product/category', 'path=' . $category_info['category_id'])
            );
            }
            }
            //end of product category
            
$stock_status = $result['stock_status'];
                $stock_qty = $result['quantity'];
			$this->data['products'][] = array(
				'product_id' => $result['product_id'],
				'thumb'   	 => $image,
				'name'    	 => $result['name'],
				'price'   	 => $price,
'stock_status'       => $stock_status,
                'stock_qty'       => $stock_qty,
                'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 130) . '..',
				'special' 	 => $special,
				'rating'     => $rating,
                'location'   => $result['location'],
				'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
				'href'    	 => $this->url->link('product/product', 'product_id=' . $result['product_id']),
                'category'   => $this->data['catprod']
			);
            
            
            
		} 




		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/latest.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/latest.tpl';
		} else {
			$this->template = 'default/template/module/latest.tpl';
		}

		$this->render();
	}
}
?>

Newbie

Posts

Joined
Wed Nov 16, 2011 8:02 am
Location - Cairns, Qld, Australia

Post by xxvirusxx » Mon Dec 10, 2012 7:51 pm

Can you change this vqmod to work on theia theme? Theia theme don`t have add buton on firstpage,only when click on category. I test this mod but don` remove add to cart buton (possible because is in another language..)

So can you change vqmod to replace price with out of stock when quantity is 0?

My Extensions | OC 3.0.3.1, 3.0.2.0, 2.3.0.2 with bugs fixed | 2.3.0.2 Custom version


Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by studiointeractive » Fri Jan 18, 2013 6:37 am

Hi,

I want to say that this is exactly what I was looking for in a plug in, but It doesn't seem to work...

I installed the plugin and I can't seem to get it to work. I'm using the latest vmod 2.2.2.. and opencart 1.5.4

I checked the actual product page, and the add to cart is still there. Any suggestions?

John P
Web Design Louisville



Posts

Joined
Thu Jan 17, 2013 3:34 pm


Post by OC2PS » Sat Jan 19, 2013 12:32 am

xxvirusxx wrote:Can you change this vqmod to work on theia theme?
Sure. Would be paid custom work. PM me if interested.

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by OC2PS » Sat Jan 19, 2013 12:34 am

studiointeractive wrote:doesn't seem to work...
Are you using Default theme?

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by OC2PS » Sat Jan 19, 2013 1:25 am

genme wrote:-products page (works when the individual product is selected)
-product compare
Sorry for the long delay in response. Somehow your message slipped through the cracks.

The extension is designed to work with the product page. Lots of customers only click on Add To Cart from product page, so it would have been a glaring omission if I hadn't included this :)

Product compare is also supported.

Once again, out-of-the-box support is only for Default theme. Making it work with custom theme is paid custom work.

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by xxvirusxx » Tue Jan 22, 2013 9:58 pm

Tested on Default theme, fresh install 1.5.4.1 replace add to cart on products with stock 0, but don`t show Add to cart for product with stock >1.

I disable this mode show Ad to cart. It is a bug?

My Extensions | OC 3.0.3.1, 3.0.2.0, 2.3.0.2 with bugs fixed | 2.3.0.2 Custom version


Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by OC2PS » Wed Jan 23, 2013 1:30 am

xxvirusxx wrote:Tested on Default theme, fresh install 1.5.4.1 replace add to cart on products with stock 0, but don`t show Add to cart for product with stock >1.
That shouldn't happen. You probably have another vqmod affecting the page, and messing with the code.

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by xxvirusxx » Thu Jan 31, 2013 5:05 pm

Tested again without another vqmod, only with this vqmod. Tested on 3 products only 2 have out of stock and the third product has this error:

Notice: Undefined variable: stock_qty in catalog/view/theme/default/template/product/product.tpl on line 210 Notice: Undefined variable: stock_status in catalog/view/theme/default/template/product/product.tpl on line 211

My Extensions | OC 3.0.3.1, 3.0.2.0, 2.3.0.2 with bugs fixed | 2.3.0.2 Custom version


Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by OC2PS » Thu Jan 31, 2013 7:43 pm

xxvirusxx wrote:error
Are you using OC 1.4 or 1.4.1?
Are you using v1.2 of this module?

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by Mouratov » Tue Feb 12, 2013 5:50 am

xxvirusxx wrote:Tested again without another vqmod, only with this vqmod. Tested on 3 products only 2 have out of stock and the third product has this error:

Notice: Undefined variable: stock_qty in catalog/view/theme/default/template/product/product.tpl on line 210 Notice: Undefined variable: stock_status in catalog/view/theme/default/template/product/product.tpl on line 211
Hello

First thanks for this extension, i have same issue but in line 217 and 216, out of stock appear but, the button, appear the error.
On the list product its ok, but when enter to the product(out of stock) its suppost not appear add to cart, appear the msg

Notice: Undefined variable: stock_qty in catalog/view/theme/default/template/product/product.tpl on line 216 and 217

Thanks

Newbie

Posts

Joined
Mon Dec 24, 2012 3:25 am

Post by OC2PS » Tue Feb 12, 2013 3:45 pm

This means either you are not using correct versions (OpenCart 1.5.4.1, Default theme and v1.2 of this module) or there is another vqmod making changes to product page that is making this module unusable.

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by Mouratov » Wed Feb 13, 2013 10:07 pm

Hello

i download the correct one, but same error i get, line 216 and 217.
I have to put on root/vqmod/xml, and not upload...

But get same error, when i open the product, if i see on list products its ok!
How can i pass this?!

Thanks

Newbie

Posts

Joined
Mon Dec 24, 2012 3:25 am

Post by nashirr » Mon Mar 04, 2013 6:56 am

how to use it on other template ?

and why Parse error: syntax error, unexpected $end in /home/nashirrn/public_html/store/vqmod/vqcache/vq2-catalog_view_theme_theia_template_product_product.tpl on line 480 ?

Newbie

Posts

Joined
Mon Mar 04, 2013 6:55 am

Post by OC2PS » Mon Mar 04, 2013 11:01 pm

nashirr wrote:how to use it on other template ?
All themes are different. This mod is written for Default theme. Making this mod work with other themes is custom work. You'll need to hire someone to do it if you can't yourself. You can PM me to have a look as well, but be warned that my turnaround time is well over 48 hrs.

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by richdtt » Tue Mar 26, 2013 1:52 am

Hi. Are out-of-stock items, located under the "Related Products" tab showing "out of stock" instead of the "add to cart" button for anybody?
It's not doing that for mine, and maybe I'm missing something, but when I looked at the code, the only change to the product.tpl file seems to be the main "add to cart" button for the main product. It doesn't seem to do anything to the related products.

Newbie

Posts

Joined
Wed Mar 21, 2012 9:26 am

Post by imagineds » Wed Jul 31, 2013 5:21 am

This is working for me. My question is how would I get this to also remove the QTY title and field for items out of stock? Thank you.

Newbie

Posts

Joined
Fri Oct 05, 2012 5:57 am

Post by dosker » Fri Nov 22, 2013 11:48 pm

Hi,
it works great but it doesn't work with featured items.
Here should be some other variable instead of $stock_qty. Unfortunatelly I can't find out how correct this.

<file name="catalog/view/theme/*/template/product/product.tpl">
<operation>
<search position="replace"><![CDATA[<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />]]></search>
<add><![CDATA[<?php if ($stock_qty <= 0) {
echo "<span style=\"color: red; font-size: 16px;\"><span class=\"outofstock\">" . $stock_status . "</span></span>";
} else {
echo "<input type=\"button\" value=\"" . $button_cart . "\" id=\"button-cart\" class=\"button\" />";
} ?>]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><?php echo $button_cart; ?></a>]]></search>
<add><![CDATA[<?php if ($stock_qty <= 0) {
echo "<span style=\"color: red; font-size: 16px;\"><span class=\"outofstock\">" . $stock_status . "</span></span>";
} else {
echo "<a onclick=\"addToCart('" . $product['product_id'] . "');\" class=\"button\">" . $button_cart . "</a>";
} ?>]]></add>
</operation>
</file>


In your case if main product is unavailable then all other realted products are also unavailable.

Newbie

Posts

Joined
Fri Nov 22, 2013 11:41 pm

Post by OC2PS » Sat Nov 23, 2013 6:57 pm

dosker wrote:it works great but it doesn't work with featured items.
dosker wrote:In your case if main product is unavailable then all other realted products are also unavailable.
I think you mean if main product is unavailable then all "product options" are unavailable too. That's correct. That's how this extension works. The reason is that's how OpenCart works.

OC2PS
OC 2.3.0.2, vQmod 2.6.2, Journal2 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by garywinner » Wed Dec 11, 2013 11:15 pm

Hello,

Thanks for sharing.
I installed in on my OC 1.5.6 but it doesn't work and ruin the layout of homepage.
Here is the errors at the top of the page.

Notice: Undefined variable: product_info in ....\vqmod\vqcache\vq2-catalog_controller_module_bestseller.php on line 99
Notice: Undefined variable: product_info in ....\vqmod\vqcache\vq2-catalog_controller_module_bestseller.php on line 100

Glad if there are any advice.
Thanks!

New member

Posts

Joined
Sun Sep 01, 2013 6:31 pm
Location - Hong Kong
Who is online

Users browsing this forum: No registered users and 3 guests