VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: soura123 on October 30, 2018, 07:37:08 AM

Title: display text if manufacturer id
Post by: soura123 on October 30, 2018, 07:37:08 AM
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
Title: Re: display text if manufacturer id
Post by: StefanSTS on October 30, 2018, 08:33:31 AM
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
Title: Re: display text if manufacturer id
Post by: GJC Web Design on October 30, 2018, 11:59:24 AM
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>';

}
Title: Re: display text if manufacturer id
Post by: soura123 on October 30, 2018, 12:36:31 PM
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 (
Title: Re: display text if manufacturer id
Post by: GJC Web Design on October 30, 2018, 14:07:00 PM


if its an array use it as an array!

$pid = $this->product->virtuemart_manufacturer_id[0];
Title: Re: display text if manufacturer id
Post by: soura123 on October 30, 2018, 16:29:51 PM
oh yeah
that did the trick
thanks you are great!