VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: guybr on November 06, 2014, 08:18:09 AM

Title: how to display 'sold' if there is no price?
Post by: guybr on November 06, 2014, 08:18:09 AM
Hi, when I have products that have sold, I set their base price to 0 and set their availability to "sold" and "in stock" to 0 in the product configuration.

I see that VM nicely displays "sold" on the product details screen and does not display a price.

How can I configure the php on the product listing pages, so that when there is no price (or $0 price), instead of displaying nothing it displays the label "sales price" and the word "sold"?

I tried this without success on category/default.php:
AFTER the segment that starts
               <div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
                  <?php
                  if ($this->show_prices == '1') {

                  } ?>
//close of above section

I added this
//start of my code:
                  <?php if (empty($product->prices)) {
                        echo $this->product->product_availability;
                  } ?>

Title: Re: how to display 'sold' if there is no price?
Post by: guybr on November 06, 2014, 11:19:47 AM
almost there (I had an erronious $this-> in the above snippet):

this works when included in the overall php condition that was above it

                     if (empty($product->prices['salesPrice']) || $product->prices['salesPrice']<=0) {
                        echo 'Price: ';
                        echo $product->product_availability;

1 question remains: instead of hardcoding 'Price' in the code, how do I get the actual "base price" label to display with the value from the product availability?