Page 1 of 1

Customer group ID

Posted: Thu May 08, 2014 8:52 pm
by pablich
Hi, im trying to get de Customer group ID in this file:

catalog/model/catalog/obtendatos.php

Code: Select all

<?php
require_once('../../../config.php');
require_once(DIR_SYSTEM . 'startup.php');
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$q=$_GET["q"];
$resultado = mysql_query("SELECT * FROM product WHERE model LIKE '%" . $q . "%'");
while($row = mysql_fetch_array($resultado))
  {
 $special_query = mysql_query("SELECT * FROM product_special WHERE product_id LIKE '%" . $row['product_id'] . "%' AND customer_group_id LIKE '%" . $this->customer->getCustomerGroupId . "%'");
 $row_s = mysql_fetch_array($special_query);
if ($row['quantity'] > 0) {
$disponible = 7;
$stock_query = mysql_query("SELECT * FROM stock_status WHERE stock_status_id LIKE '%" . $disponible . "%'");
$stock = mysql_fetch_array($stock_query);
$rstock = $stock['name'];
}
if ($row['price']) { 
echo '<div class="price">';      
 if (!$row_s['price']) { 
echo '<span>';
echo 'Precio: ';
echo '</span>'; 
echo $row['price']; 
} else { 
echo '<span>';
echo 'Precio: ';
echo '</span>';
echo '<span class="price-new">';
echo $row_s['price'];
echo '</span>';
} 
echo '</div>';
 } 
echo '<div class="actions">';
echo '<div class="cart">';
 if ($row['price']) { 
echo $rstock; 
echo '<br>';
 } 

 echo 'Cantidad: ';
 echo '<input type="text" name="quantity" value="" class="input-mini" id="quantity-'.$row['product_id'].'">';
 if ($rstock !== "Sin disponibilidad") { 
echo '<br><input id="boton" name="boton" type="button" value="AƱadir a la cesta" onclick="addQtyToCart(';
echo "'";
echo $row['product_id'];
echo "'";
echo ');" class="btn btn-cart btn-small" />';
 } 
echo '</div>';
echo '</div>';
}
?>
$this->customer->getCustomerGroupId NOT FOUND. Can someone help me? Thanks you!!

Re: Customer group ID

Posted: Sun May 11, 2014 1:04 pm
by MarketInSG
$this->customer->getCustomerGroupId() is the correct way. You're missing the brackets at the end..

Re: Customer group ID

Posted: Mon May 12, 2014 11:57 am
by pablich
MarketInSG wrote:$this->customer->getCustomerGroupId() is the correct way. You're missing the brackets at the end..
Yes, i try, but show that error: $this is a invalid argument

Re: Customer group ID

Posted: Mon May 12, 2014 5:19 pm
by MarketInSG
just realised you aren't writing this in OOP. Then of course it wouldn't work. Look into how the model files are written, and how the controller files are written.

Re: Customer group ID

Posted: Mon May 12, 2014 8:28 pm
by pablich
MarketInSG wrote:just realised you aren't writing this in OOP. Then of course it wouldn't work. Look into how the model files are written, and how the controller files are written.
This is because I use this file in:

function showUser(str,num){
if (str==""){
document.getElementById("cargarproducto"+num).innerHTML="";
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("cargarproducto"+num).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","catalog/model/catalog/id.php?q="+str,true);
xmlhttp.send();
}

Re: Customer group ID

Posted: Mon May 12, 2014 9:29 pm
by MarketInSG
You can still send a get request correctly to index.php?route=xxx/yyy