News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

display text if manufacturer id

Started by soura123, October 30, 2018, 07:37:08 AM

Previous topic - Next topic

soura123

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

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

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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

soura123

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



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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

soura123

oh yeah
that did the trick
thanks you are great!