News:

Support the VirtueMart project and become a member

Main Menu

Product Page Fields For Templating

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

Previous topic - Next topic

Alberto87


PRO

Quote from: Alberto87 on June 18, 2013, 15:04:41 PM
Yes, i use virtuemart in multi languages.

I want to know, if for every language I can write/set a specific text.

Right now I have an image and it doesn't change for each language.

Can you please help me?

Thanks!
Cheers,
Alberto

The code below will have 4 different results for availability
It tests for availability values of 1,2,3, and 4

THEN it adds a language string
You can do your own language strings inside your language overrides
http://forum.virtuemart.net/index.php?topic=92944.0

You can even add an image link inside your language override

<?php if ($this->product->product_availability ==1){
echo JText::_('COM_VIRTUEMART_PRODUCT_AVAIL1');}
elseif ($this->product->product_availability ==2){
echo JText::_('COM_VIRTUEMART_PRODUCT_AVAIL2');}
elseif ($this->product->product_availability ==3){
echo JText::_('COM_VIRTUEMART_PRODUCT_AVAIL3');}
elseif ($this->product->product_availability ==4){
echo JText::_('COM_VIRTUEMART_PRODUCT_AVAIL4');}
?>


let me know if this gets you going in the right direction

Alberto87

Hello,

ok, but where i can add this code?

<?php if ($this->product->product_availability ==1){
echo 
JText::_('COM_VIRTUEMART_PRODUCT_AVAIL1');}
elseif (
$this->product->product_availability ==2){
echo 
JText::_('COM_VIRTUEMART_PRODUCT_AVAIL2');}
elseif (
$this->product->product_availability ==3){
echo 
JText::_('COM_VIRTUEMART_PRODUCT_AVAIL3');}
elseif (
$this->product->product_availability ==4){
echo 
JText::_('COM_VIRTUEMART_PRODUCT_AVAIL4');}
?>



can i replace this ?

// Availability Image
/* TO DO add width and height to the image */
if (!empty($this->product->product_availability)) {
   $stockhandle = VmConfig::get('stockhandle', 'none');
if ($stockhandle == 'risetime' and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
    ?> <div class="availability">
    <?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' VmConfig::get('rised_availability''7d.gif'), VmConfig::get('rised_availability''7d.gif'), array('class' => 'availability')); ?>
    </div>
<?php } else {
    
?>

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

PRO



this is the complete availability block


      <?php
      // Availability Image
      $stockhandle = VmConfig::get('stockhandle', 'none');
      if (($this->product->product_in_stock - $this->product->product_ordered) < 1) {
         if ($stockhandle == 'risetime' and VmConfig::get('rised_availability') and empty($this->product->product_availability)) {
         ?>   <div class="availability">
             <?php echo (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability'))) ? JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability', '7d.gif'), VmConfig::get('rised_availability', '7d.gif'), array('class' => 'availability')) : JText::_(VmConfig::get('rised_availability')); ?>
         </div>
          <?php
         } else if (!empty($this->product->product_availability)) {
         ?>
         <div class="availability">
         <?php echo (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . $this->product->product_availability)) ? JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $this->product->product_availability, $this->product->product_availability, array('class' => 'availability')) : JText::_($this->product->product_availability); ?>
         </div>
         <?php
         }
      }
      ?>



please make sure to backup your file

Robert_ITMan

Please help! Availability is not dynamic enough for us - why can't we just use the stock levels? How do we get this to work on product details like we have on category?

category/default.php
<span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"><?php echo $product->product_in_stock ?></span>
:) works perfectly result example: <span class="vmicon vm2-normalstock" title="Order Now">15</span>

productdetails/default.php
<span class="vmicon vm2-<?php echo $this->product->stock->stock_level ?>" title="<?php echo $this->product->stock->stock_tip ?>"><?php echo $this->product->product_in_stock ?></span>
>:( does not work result example:  <span class="vmicon vm2-" title="">15</span>
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

PRO

what do you want to do with availability?

<?php echo $this->product->product_in_stock ?> 
can be used

I use a estimated ship date & estimated delivery date. Then, just store availability by the # of days it takes to ship.

<?php
// Check to ensure this file is included in Joomla!
defined ( '_JEXEC' ) or die ( 'Restricted access' );
$daystoship= $this->product->product_availability;
$daystodelivery= $daystoship + 5;
$ship_date = date('md', strtotime(" + $daystoship Weekdays"));
$estimated_ship_date= $ship_date;
$delivery_date = date('md', strtotime("+ $daystodelivery Weekdays"));
$mo = substr($estimated_ship_date, 0, 2);
$da = substr($estimated_ship_date, 2, 2);
$dmo = substr($delivery_date, 0, 2);
$dda = substr($delivery_date, 2, 2);
$est = $mo . "/" . $da;
$estd = $dmo . "/" . $dda;
?>



then i do on the page
<?php echo JText::_('COM_VIRTUEMART_ESD') ?><?php echo $est; ?></li><li> <?php echo JText::_('COM_VIRTUEMART_ARRIVE') ?><?php echo $estd; ?>

You could easily write your own code to also take into account the # of products in stock

Robert_ITMan

#66
PRO - thanks for quick reply, you inspired me to get it working! This code now works for me so stock in productdetails/default.php is just like we have in category/default.php :)
<?php // Stock and Level and Tip
 if ($this->product->product_in_stock 0) {
if ($this->product->product_in_stock <= $this->product->low_stock_notification) {
  $this_stock_level 'lowstock';
  $this_stock_tip JText::_("COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_LOW_TIP");
} else {
  $this_stock_level 'normalstock';
  $this_stock_tip JText::_("COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_NORMAL_TIP");
}
 } else {
  $this_stock_level 'nostock';
  $this_stock_tip JText::_("COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_OUT_TIP");
 } ?>

<span class="vmicon vm2-<?php echo $this_stock_level ?>" title="<?php echo $this_stock_tip ?>"><?php echo $this->product->product_in_stock ?></span>
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

bdimov

Hi,

I use this for displaying manufacturer name in product:
<?php echo $this->product->mf_name ?>

My question:
Is there any way to make when I go to product and see that manufacturer name to click and go to manufacturer info page?
I want when I click to manufacturer name to redirects me to manufacturers info page...?

PRO

Quote from: bdimov on March 13, 2014, 18:07:02 PM
Hi,

I use this for displaying manufacturer name in product:
<?php echo $this->product->mf_name ?>

My question:
Is there any way to make when I go to product and see that manufacturer name to click and go to manufacturer info page?
I want when I click to manufacturer name to redirects me to manufacturers info page...?

the manufacturer link is standard in vmart product page, IF you choose to show manufacturer

lliseil

Many thanks to PRO for this topic's information.

To override product details layout and show the stock level image, I use the view file /templates/MYTEMPLATE/html/com_virtuemart/productdetails/default.php
That does not work by simply adding '$this->' to what works for Category page Field overrides. Here's my test:
<?php // Stock Info 
echo $this->product->stock_level    // print nothing
echo $this->product->product_availability;   // print nothing 
echo $this->product->product_in_stock   // works
?>


The logic's somehow out of my mind.

But Robert_ITMan's code with '$this_stock_{level,tip}' works beautifully :)

ps : not '$this_product-availabity'.
- A thread solved is a thread [SOLVED]! (a memo for myself)

tzic

Hello,

I am trying to display "Units in box" in my details page. Is there a way to do it or it is just a dummy entry in Virtuemart?

PS I am not reffering to Product Unit: <?php echo $this->product->product_unit ?>

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


GJC Web Design

For further reference  "Units in Box" is  <?php echo $this->product->product_box ?>
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

kelecz

Quote from: TimHoogland on June 05, 2012, 22:48:38 PM
Hello,

<?php echo $this->product->product_width ?>
<?php echo $this->product->product_height ?>

I succeed in adding this two rows in an override file, but now the numbers are presented like:

Hoogte :60.0000 cm.
Potmaat :17.0000 cm.


How can I present integers instead of the above format?

Like to hear from you,

Tim Hoogland

In your phpAdmin : see picturs




[attachment cleanup by admin]

Robert_ITMan

Quote from: TimHoogland on June 05, 2012, 22:48:38 PM
I succeed in adding this two rows in an override file, but now the numbers are presented like:
Hoogte :60.0000 cm.
Potmaat :17.0000 cm.
How can I present integers instead of the above format?

Do NOT edit your database as kelecz suggested - next VM update will fix your tables and remove this change -  which you will want when calculating shipping costs for better accuracy.

Instead use php number_format to display them as you wish, see: http://php.net/manual/en/function.number-format.php
<?php echo number_format($this->product->product_width, 2, '.', ','); ?> // 60.00
<?php echo number_format($this->product->product_height, 0, '.', ','); ?> // 17
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

kelecz

Great,

in which file? I try to do that in my overide defoult.php but nothing.

I will be grateful for help.