News:

Looking for documentation? Take a look on our wiki

Main Menu

Product Page Fields For Templating

Started by PRO, November 03, 2011, 17:16:20 PM

Previous topic - Next topic

PRO

Product Page Fields:
For category fields, look here http://forum.virtuemart.net/index.php?topic=97744.0

PLEASE see http://forum.virtuemart.net/index.php?topic=98505.0


Product Name
<?php echo $this->product->product_name ?>

Product SKU
<?php echo $this->product->product_sku ?>

Ask a question about this product
<a class="ask-a-question" href="<?php echo $url ?>" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>
Short Description
   <?php echo $this->product->product_s_desc ?>

Product Full Description
      <?php echo $this->product->product_desc ?>

Product MAIN Image (the 0 is the column number for the 1st image)
<?php echo $this->product->images[0]->displayMediaFull('class="product-image"',false) ?>

Additional Images (>1 means all images past the 1st image)
      <?php if(!empty($this->product->images) && count($this->product->images)>1) {
         foreach ($this->product->images as $image) {
            echo $image->displayMediaThumb('class="product-image"',true,'class="modal"'); //'class="modal"'
         }
}
?>

Product Availability AS TEXT
<?php echo $this->product->product_availability; ?>

Product Availability As Picture
<?php echo JHTML::image(JURI::root().VmConfig::get('assets_general_path').'images/availability/'.$this->product->product_availability, $this-
>product->product_availability, array('class' => 'availability')); ?>

Minimum Order Level
<?php echo $this->product->min_order_level ?>

Maximum Order Level
<?php echo $this->product->max_order_level ?>

Product Unit
<?php echo $this->product->product_unit ?>

Product Weight
<?php echo $this->product->product_weight ?>

Product Weight Unit of Measure
<?php echo $this->product->product_weight_uom ?>

Product Length
<?php echo $this->product->product_length ?>

Product Width
<?php echo $this->product->product_width ?>

Product Height
<?php echo $this->product->product_height ?>

Product URL
<?php echo $this->product->product_url ?>

Product # In Stock
<?php echo $this->product->product_in_stock ?>

Product Availability Date
<?php echo $this->product->product_available_date ?>

Product Special 0 or 1 0 for no, 1 for yes.
<?php echo $this->product->product_special ?>

Product Packaging
<?php echo $this->product->product_packaging ?>

Create a link to the product's main category from the product page.
$catturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.JRequest::getInt('virtuemart_category_id',0));

<a href="<?php echo $catturl ?>"><?php echo $this->category->category_name ?></a>

Manufacturer Name
<?php echo $this->product->mf_name ?>

PRO

#1
All Fields Above can be used for extra fields, and features on the product page.

For example. I use product weights of 0 to be items with free shipping. So, to display "FREE Shipping"  to the user, I do this.

<?php if ($this->product->product_weight == 0) { ?>
                  <div>Free Shipping on this Item! Minimum Order Quantity <?php echo $this->product->min_order_level ?></div>
               <?php    }?>

So the code above shows free shipping, and the minimum quantity order amount.

You can do the same with most fields.

To display an icon, or text if a product is featured you can do this.

<?php if ($this->product->product_special == 1) { ?>
                  <div>SALE ITEM!!!!! </div>
               <?php    }?>

Tell the customer the stock is low, and they should order NOW!
<?php if ($this->product->product_in_stock <= 10) { ?>
                  <div>ONLY <?php echo $this->product->product_in_stock ?> In Stock. ORDER BEFORE IT'S TOO LATE</div>
               <?php    }?>

kode5

Hi,

I tried for several hours now, and I can't figure out how to use the Product Page Fields.

Can someone please make a guide/tutorial for noobs like me?

Thanks in advance.
Daniel


kode5

I can't get it to work.
Can you please give an example of an edited product details page default.php including Product SKU:
Product SKU
<?php echo $this->product->product_sku ?>

PRO

Quote from: kode5 on November 21, 2011, 21:18:03 PM
I can't get it to work.
Can you please give an example of an edited product details page default.php including Product SKU:
Product SKU
<?php echo $this->product->product_sku ?>


USE and override,
http://forum.virtuemart.net/index.php?topic=90935.0

and how is it not working?

matteo

Can i get the from an overridden product details page the url of the main image and the additional images?
I'd like to build a different <img> tag, so I need the file_url_thumb used in the "VmImage" class I think.

PRO


matteo

I'm sorry, I'll try to explain it better:
I have a view to modify: /templates/MYTEMPLATE/html/com_virtuemart/productdetails/default.php
If I use the "page field" echo $this->product->images[0]->displayMediaFull('class="product-image"',false) I get as generated code this:
<div class="main-image">
<img src="MY_IMAGE_URL.jpg" alt="MYIMAGENAME" class="product-image"><span class="vm-img-desc">MY_IMAGE_NAME</span>
</div>

and for the for the additional images, if I use the "page field" echo $image->displayMediaThumb('class="product-image"',true,'class="modal"',true,true); I get this:
<div class="additional-images">
<a title="MY_IMAGE_NAME" class="modal" href="MY_IMAGE_URL.jpg"><img src="MY_THUMB_URL.jpg" alt="MY_IMAGE_NAME" class="product-image"></a><span class="vm-img-desc">MY_IMAGE_NAME</span>
<a title="MY_IMAGE_NAME" class="modal" href="MY_IMAGE_URL.jpg"><img src="MY_THUMB_URL.jpg" alt="MY_IMAGE_NAME" class="product-image"></a><span class="vm-img-desc">MY_IMAGE_NAME</span>
</div>


I need to use in the /templates/MYTEMPLATE/html/com_virtuemart/productdetails/default.php the url of the images and of the thumbnails so I can have as generated code a different html structure like (for example) this:
<div id="MY_ID">
<div class="MY_CLASS">
<ul class="MY_CLASS">
  <li><li style="position: absolute; left: 17px; "><img src="MY_THUMB_URL01.jpg" width="80" height="45" alt="MY_IMAGE_NAME01"></li></li>
  <li><li style="position: absolute; left: 107px; "><img src="MY_THUMB_URL02.jpg" width="80" height="45" alt="MY_IMAGE_NAME02"></li></li>
</ul>
</div>
</div>

PRO

what do you want it to look like? it seems you are going the wrong way about this

matteo

I'd like to generate the right structure to use another kind of lightbox or gallery.
I'd like to try with Widgetkit .
The structure they use to generate the galleries is this:

<div id="gallery-<?php echo $widget_id?>" class="wk-slideshow wk-slideshow-default" data-widgetkit="slideshow" data-options='<?php echo json_encode($settings); ?>'>
<div>
<ul class="slides">

<?php foreach ($images as $image) : ?>
           
<?php
$navigation[] = '<li><span></span></li>';
$captions[]   = '<li>'.(strlen($image['caption']) ? $image['caption']:"").'</li>';
$lightbox     '';

/* Prepare Lightbox */
if ($settings['lightbox'] && !$image['link']) {
$lightbox 'data-lightbox="group:'.$widget_id.'"';
}

/* Prepare Image */
$content '<img src="'.$image['cache_url'].'" width="'.$image['width'].'" height="'.$image['height'].'" alt="'.$image['filename'].'" />';

/* Lazy Loading */
$content = ($i==$settings['index']) ? $content $this['image']->prepareLazyload($content);
?>


<?php if ($settings['lightbox'] || $image['link']) : ?>
<li><a class="" href="<?php echo $image['link'] ? $image['link'] : $image['url']; ?>" <?php echo $lightbox?>><?php echo $content?></a></li>
<?php else : ?>
<li><?php echo $content?></li>
<?php endif; ?>

<?php $i=$i+1;?>
<?php endforeach; ?>

</ul>
        <?php if ($settings['buttons']): ?><div class="next"></div><div class="prev"></div><?php endif; ?>
<div class="caption"></div><ul class="captions"><?php echo implode(''$captions);?></ul>
</div>
<?php echo ($settings['navigation'] && count($navigation)) ? '<ul class="nav">'.implode(''$navigation).'</ul>' '';?>
</div>

and I'd like to modify it and use VirtueMart images and product variables.


matteo

Thanks, so I'll use something like this to get the thumbnail list:
<ul class="MY_CLASS">
<?php // List all Images
foreach ($this->product->images as $image) {
?>
<li <?php echo $thstyle?>><img src="<?php echo $image->file_url_thumb?>" width="80" height="45" alt="MY_IMAGE_NAME01"></li>
<?php
?>

</ul>

Mole_LR

Hello!
What about Product page fields for Prices (all variants), for checking does prouct has discount (for templating page with products which have discount)?

Thank You!

malibu2792

Hi, I'm trying to add the  product sku on the product details page using : "<?php echo $this->product->product_sku ?>" I have done the overwrites as explained in the above. I can not seem to figure this out. I am trying to place it before the price. What else needs to be added?

Thanks,
John