You are here:  » Picture in price comparison table


Picture in price comparison table

Submitted by peterb on Sat, 2015-08-01 16:24 in

Hello,

Is it possible and how to put a picture in the price comparison table, something like
Stockist PICTURE Catalogue Product Name Price

just like {link saved}
shown on the right site off the page

Peter

Submitted by support on Sat, 2015-08-01 16:45

Hello Peter, and welcome to the forum!

Sure - the picture field is available within the loop so can be easily added to the price comparison table.

Firstly, to modify the templates -

From /wp-admin/ > Settings > PriceTapestry.org, scroll down to the Prices / Before template and look for the following markup:

<th>Catalogue Product Name</th>

...and REPLACE with:

<th>Picture</th>
<th>Catalogue Product Name</th>

And then in Prices / Each, look for the following markup:

<td>%ORIGINAL_NAME%</td>

...and REPLACE with:

<td>
%IF_IMAGE%
<img class='pto_prices_image' src='%IMAGE_URL%' />
%ENDIF_IMAGE%
</td>
<td>%ORIGINAL_NAME%</td>

Now to modify the code to insert the image URL (if exists), edit the plugin file pto_product.php and look for the following code at line 108:

  $each = str_replace("%ORIGINAL_NAME%",$product->original_name,$each);

...and REPLACE with:

    $each = str_replace("%ORIGINAL_NAME%",$product->original_name,$each);
    if ($product->image_url)
    {
      $each = str_replace("%IMAGE_URL%",$product->image_url,$each);
      $each = str_replace("%IF_IMAGE%","",$each);
      $each = str_replace("%ENDIF_IMAGE%","",$each);
    }
    else
    {
      $each = preg_replace('/%IF_IMAGE%(.*)%ENDIF_IMAGE%/','',$each);
    }

That would complete the functionality, but now you would need to style the image as occurring in the price comparison table appropriately. To do this, edit the plugin file resources/pto.css and add a new style definition for .pto_prices_image e.g.

.pto_prices_image {
  max-width: 100px;
  max-height: 100px;
}

...or as required. Using max- styles will ensure that images remain at an appropriate size but are not distorted as a result of fixing both width and height...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by peterb on Sat, 2015-08-01 21:03

Hello, David

Thank You for the info works 100%

Thanks

Peter