hello everyone
i m trying to display a text on product view when the manufacturer id is for example 3 or 4 or 5
what i tried so far is this
<?php JRequest::setVar('virtuemart_manufacturer_id',$product->virtuemart_manufacturer_id,'GET');
if ($this->product->virtuemart_manufacturer_id ='1,2,3,4' ) {
echo '<div class="reseller"><i class="fa fa-check"></i>Reseller</div>';
}
?>
my joomla versio is 3.8.13 and vm version is 3.4.2 my php is 7.2
any ideas
thanks
Hi,
I would remove the JRequest. The variable should be in $this->product. Make a vardump to test.
You do not compare the values in your IF. == is the comparison, not =, the single one sets the variable to a value.
Use just one manufacturer_id first for testing. Maybe make some OR in the if statement.
The rest of your code should work then.
Stefan
or in_array
$allowed = array(1,2,3,4);
$pid = $this->product->virtuemart_manufacturer_id; // or in cat $pid = $product->virtuemart_manufacturer_id;
if(in_array($pid, $allowed)){
echo '<div class="reseller"><i class="fa fa-check"></i>Reseller</div>';
}
Quote<?php
$allowed = array(12,34,3,4);
$pid = $this->product->virtuemart_manufacturer_id; // or in cat $pid = $product->virtuemart_manufacturer_id;
if(in_array($pid, $allowed)){
echo '<div class="reseller"><i class="fa fa-check"></i>Reseller</div>';
}
?>
this does not work either with single id on the array
i try to print the id
with
<?php print_r ($this->product->virtuemart_manufacturer_id) ?>
and i get
Array (
- => 34 )
i try $allowed = array(34);
and still not working
bump
if its an array use it as an array!
$pid = $this->product->virtuemart_manufacturer_id[0];
oh yeah
that did the trick
thanks you are great!