Post by shotsofsurf » Sun Apr 13, 2014 3:56 am

Since updating to 1.5.6.2, I'm experiencing VQmods that are no longer functioning. To get my website functional again for customers I need help sorting out a free vqmod that updates the price automatically on the product page when an option is selected.

I've posted the default code of the free mod below to assist in trouble shooting. (not sure if this is OK to do, but the admin forum rules didn't address it and since it was a free mod and the developer doesn't normally provide support, I felt it OK to post)

Hopefully someone here can detect the issue. Basically, when an option is selected, the price is not updating as expected. Also, the vqmod is supposed to put a "=" under the price options in Admin. The "=" has now disappeared. Even though the option is selected and the price does not reflect the selected option on the product page, if the product is added to the cart, the total cart price still includes the price + options.

Code: Select all

 <modification>
        <id>price_replace_options_quantities</id>
        <version>1.9price_replace_options_quantities</version>
        <vqmver>1.0</vqmver>
        <author>ocextensions.co.uk</author>
        <file name="admin/view/template/catalog/product_form.tpl">
            <operation>
                        <search position="after" index="1" offset="1"><![CDATA[<option value="-">-</option>]]></search>
                        <add><![CDATA[                      <?php if ($product_option_value['price_prefix'] == 'z') { ?>
                      <option value="z" selected="selected"> = </option>
                      <?php } else { ?>
                      <option value="z"> = </option>
                      <?php } ?>]]></add>
              </operation> 
            <operation>
                        <search position="after"><![CDATA[html += '      <option value="-">-</option>';]]></search>
                        <add><![CDATA[        html += '      <option value="z"> = </option>';]]></add>
              </operation> 
 </file>
 <file name="system/library/cart.php">  
              <operation>
                        <search position="after"><![CDATA[$option_price -= $option_value_query->row['price'];]]></search>
                        <add><![CDATA[									} elseif ($option_value_query->row['price_prefix'] == 'z') {
										$option_price += $option_value_query->row['price'];]]></add>
              </operation>
 </file>
 <file name="catalog/controller/product/product.php">  
              <operation>
                        <search position="after" index="2" offset="3"><![CDATA[$this->response->setOutput($this->render());]]></search>
                        <add><![CDATA[public function add() {
		$this->language->load('checkout/cart');
                                       $hold = array();
		                       $json = array();
		
		if (isset($this->request->post['product_id'])) {
			$product_id = $this->request->post['product_id'];
		} else {
			$product_id = 0;
		}
		
		$this->load->model('catalog/product');
						
		$product_info = $this->model_catalog_product->getProduct($product_id);
		
		if ($product_info) {
                            if (isset($this->request->post['quantity'])) {
				$quantity = $this->request->post['quantity'];
			} else {
		       $quantity = 1;								
			}
												
			if (isset($this->request->post['option'])) {
				$option = array_filter($this->request->post['option']);
			} else {
				$option = array();	
			}
			
			$product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);
                           
			 if (isset($this->session->data['cart'])) {

                         $hold = $this->session->data['cart'];
     		         unset($this->session->data['cart']);
                            
                            if (!$option) {
      		$keyx = (int)$product_id;
    	} else {
      		$keyx = (int)$product_id . ':' . base64_encode(serialize($option));
    	}
    	                unset($this->session->data['cart'][$keyx]);
                        $this->data = array();
      			$this->session->data['cart'][$keyx] = (int)$quantity;
				$json['success'] = '0';
                                
                                unset($this->session->data['shipping_method']);
				unset($this->session->data['shipping_methods']);
				unset($this->session->data['payment_method']);
				unset($this->session->data['payment_methods']);
                                
				// Totals
				$this->load->model('setting/extension');
				
				$total_data = array();					
				$total = 0;
				$taxes = $this->cart->getTaxes();
				
				// Display prices
				if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
					$sort_order = array(); 
					
					$results = $this->model_setting_extension->getExtensions('total');
					
					foreach ($results as $key => $value) {
						$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
					}
					
					array_multisort($sort_order, SORT_ASC, $results);
					
                            
					foreach ($results as $result) {
						if ($this->config->get($result['code'] . '_status')) {
							$this->load->model('total/' . $result['code']);
				
							$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
						}
						
						$sort_order = array(); 
					  
						foreach ($total_data as $key => $value) {
							$sort_order[$key] = $value['sort_order'];
						}
			
						array_multisort($sort_order, SORT_ASC, $total_data);			
					}
				}
			if (isset($this->session->data['cart'][$keyx])) {
     		          unset($this->session->data['cart'][$keyx]);
  		                               }   
                         if ($this->config->get('config_tax') == '0') {    
                            $val = array_sum($taxes);
                          $total = $total - $val;
                               }               
                              
                  $this->session->data['cart'] = $hold;  
				$json['total'] = sprintf($this->currency->format($total));
                                          $tax = $total - array_sum($taxes);
                                  $json['tax'] =  sprintf($this->currency->format($tax));
			} else {
				$json['redirect'] = str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']));
			}
		}
		$this->response->setOutput(json_encode($json));		
	}
	]]></add>
              </operation>
 </file>
 <file name="catalog/view/theme/*/template/product/product.tpl"> 
               <operation>
                        <search position="before"><![CDATA[(<?php echo $option_value['price_prefix'];]]></search>
                        <add><![CDATA[                  <?php  if ($option_value['price_prefix'] != 'z') {?>]]></add>
               </operation>  
               <operation>
                        <search position="after"><![CDATA[(<?php echo $option_value['price_prefix'];]]></search>
                        <add><![CDATA[                    <?php } else { ?> : <?php echo $option_value['price']; }?>]]></add>
               </operation>  
               <operation>
                        <search position="replace"><![CDATA[<input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />]]></search>
                        <add><![CDATA[               <input id='bc' type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />]]>
                        </add>
               </operation> 
                <operation>
                        <search position="replace" index='1'><![CDATA[<?php echo $text_price; ?>]]></search>
                        <add><![CDATA[<?php // echo $text_price; ?>]]></add>
                </operation>
                <operation>
                        <search position="replace" index='1'><![CDATA[<?php echo $price; ?>]]></search>
                        <add><![CDATA[         <div class="opprice"><?php echo $text_price; ?><?php echo $price; ?></div>
                                            ]]>
                        </add>
                </operation>
                <operation>
                        <search position="replace" index='1'><![CDATA[<span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span><br />]]></search>
                        <add><![CDATA[<div class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></div>]]>
                        </add>
                </operation>
                <operation>
                        <search position="replace" index='1'><![CDATA[<span class="price-new"><?php echo $special; ?></span>]]></search>
                        <add><![CDATA[<span class="price-new"><div class="opprice"><?php echo $text_price; ?><?php echo $special; ?></div></span>]]></add>
                </operation>
                <operation>
                        <search position="after" index='1'><![CDATA[//--></script>]]></search>
                        <add><![CDATA[<script type="text/javascript"><!--
function a(){ 
	$.ajax({
		url: 'index.php?route=product/product/add',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
					}
				}
			} 
			if (json['success']) {
				$('.opprice').html ('<?php echo $text_price; ?>' + json['total']);
                                $('.price-tax').html ('<?php echo $text_tax; ?> ' + json['tax']);
                            html = '';
                            $.each(json.oprice, function(i, object) {   
                                                           html += object;
                                                                 });
                              $('.pandc').html(html);
		                          }
	    }
	});
} 
$(document).on("change", ".option", a);
$(document).on("keyup", "#bc", a);    
	
$( document ).ready(function() { 
	$.ajax({
		url: 'index.php?route=product/product/add',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
					}
				}
			} 
			if (json['success']) {
			   html = '';
                            $.each(json.oprice, function(i, object) {   
                                                           html += object;
                                                                 });
                              $('.pandc').html(html);
		                          }
	    }
	});
});
//--></script>
]]>
                        </add>
                </operation>
  </file>
 </modification>
Last edited by shotsofsurf on Mon Apr 14, 2014 10:22 pm, edited 1 time in total.

Newbie

Posts

Joined
Sat Mar 15, 2014 2:09 am

Post by vitalworks » Mon Apr 14, 2014 3:05 am

Same here. Updated yesterday to resolve bug where I couldnt delete items in Chrome (now resolved) but now all my vQmods dont work! Pavo Blogs, Testimonials, and a new SEO keyword mod, all not working...

Newbie

Posts

Joined
Mon Apr 14, 2014 3:01 am

User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by shotsofsurf » Mon Apr 14, 2014 11:11 am

MarketInSG wrote:Have you updated your vqmod after upgrading your opencart?
Didn't know there was an update... I'll have to check that out and see if that fixes it. Did this work for your?

Newbie

Posts

Joined
Sat Mar 15, 2014 2:09 am

Post by shotsofsurf » Mon Apr 14, 2014 11:13 am

OK, so a check of the VQMod site shows that there hasn't been an update to VQMod since Jul. 2013. So I know I'm running the latest version.

Still need a solution for this. Unless you meant something else by stating "updated your vqmod?"

Newbie

Posts

Joined
Sat Mar 15, 2014 2:09 am

Post by rph » Mon Apr 14, 2014 11:27 am

Make sure you've re-installed vQmod after an update and check your error logs to find where any issues may lie.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by shotsofsurf » Mon Apr 14, 2014 10:22 pm

Thanks! I just read more documentation on VQMod... I missed the all caps, bold text that reads:
"YOU MUST RUN THE INSTALLER EVERY TIME YOU UPGRADE OPENCART!!"
Doh! *palm to forehead*

Marking thread as 'Solved." Website vqmods working now. Thanks so much for the replies to set me on the right track!

Newbie

Posts

Joined
Sat Mar 15, 2014 2:09 am

Post by sirena » Tue Apr 15, 2014 6:56 pm

How must i re-install Vqmod ?

Newbie

Posts

Joined
Mon Apr 14, 2014 8:16 pm

Post by OSWorX » Tue Apr 15, 2014 7:59 pm

sirena wrote:How must i re-install Vqmod ?
Same procedure as you have installed it for the first time.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by shotsofsurf » Wed Apr 16, 2014 12:03 am

sirena wrote:How must i re-install Vqmod ?
It may be helpful to note that you do not need to "un-install" or delete any files before doing the re-install. Just put the install URL into your browser and BAM, re-installed.

Newbie

Posts

Joined
Sat Mar 15, 2014 2:09 am
Who is online

Users browsing this forum: No registered users and 3 guests