News:

Looking for documentation? Take a look on our wiki

Main Menu

how to display 'sold' if there is no price?

Started by guybr, November 06, 2014, 08:18:09 AM

Previous topic - Next topic

guybr

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;
                  } ?>


guybr

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?