Author Topic: Product Page Fields For Templating  (Read 217034 times)

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+
Product Page Fields For Templating
« on: November 03, 2011, 17:16:20 pm »
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

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+
Re: Product Page Fields For Templating
« Reply #1 on: November 04, 2011, 18:05:39 pm »
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

  • Beginner
  • *
  • Posts: 7
Re: Product Page Fields For Templating
« Reply #2 on: November 19, 2011, 14:28:48 pm »
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

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+

kode5

  • Beginner
  • *
  • Posts: 7
Re: Product Page Fields For Templating
« Reply #4 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:
Code: [Select]
Product SKU
<?php echo $this->product->product_sku ?>

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+
Re: Product Page Fields For Templating
« Reply #5 on: November 21, 2011, 21:51:57 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:
Code: [Select]
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

  • Beginner
  • *
  • Posts: 28
Re: Product Page Fields For Templating
« Reply #6 on: January 20, 2012, 17:34:01 pm »
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

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+
Re: Product Page Fields For Templating
« Reply #7 on: January 20, 2012, 17:53:28 pm »
what?

matteo

  • Beginner
  • *
  • Posts: 28
Re: Product Page Fields For Templating
« Reply #8 on: January 20, 2012, 18:32:52 pm »
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:
Code: [Select]
<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:
Code: [Select]
<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:
Code: [Select]
<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

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+
Re: Product Page Fields For Templating
« Reply #9 on: January 20, 2012, 18:44:30 pm »
what do you want it to look like? it seems you are going the wrong way about this

matteo

  • Beginner
  • *
  • Posts: 28
Re: Product Page Fields For Templating
« Reply #10 on: January 20, 2012, 18:58:23 pm »
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:

Code: [Select]
<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.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10440
  • VirtueMart Version: 3+

matteo

  • Beginner
  • *
  • Posts: 28
Re: Product Page Fields For Templating
« Reply #12 on: January 20, 2012, 20:39:38 pm »
Thanks, so I’ll use something like this to get the thumbnail list:
Code: [Select]
<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

  • Beginner
  • *
  • Posts: 34
Re: Product Page Fields For Templating
« Reply #13 on: February 01, 2012, 17:41:37 pm »
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

  • Beginner
  • *
  • Posts: 27
Re: Product Page Fields For Templating
« Reply #14 on: February 07, 2012, 18:38:40 pm »
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