Author Topic: display text if manufacturer id  (Read 528 times)

soura123

  • Beginner
  • *
  • Posts: 19
display text if manufacturer id
« 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

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 516
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: display text if manufacturer id
« Reply #1 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
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9194
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: display text if manufacturer id
« Reply #2 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>';

}
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

soura123

  • Beginner
  • *
  • Posts: 19
Re: display text if manufacturer id
« Reply #3 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 (
  • => 34 )

i try $allowed = array(34);
and still not working
bump

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9194
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: display text if manufacturer id
« Reply #4 on: October 30, 2018, 14:07:00 pm »


if its an array use it as an array!

$pid = $this->product->virtuemart_manufacturer_id[0];
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

soura123

  • Beginner
  • *
  • Posts: 19
Re: display text if manufacturer id
« Reply #5 on: October 30, 2018, 16:29:51 pm »
oh yeah
that did the trick
thanks you are great!