You are here:  » Wordpress shortcodes


Wordpress shortcodes

Submitted by sanniep on Tue, 2017-01-24 12:32 in

Hi David,

Another, more nice to have, thing. Is it possible to use the EAN code in the shortcode instead of the product name?

Kind regards, Sander

Submitted by support on Tue, 2017-01-24 15:30

Hi,

Sure - the most important consideration is that an index is added to the "ean" field so that the database can implement the OR clause in the SELECT SQL without needing a full table scan.

Assuming that you have added "ean" as a custom field, firstly create the following dbmod.php and run once from the top level folder of your Price Tapestry installation to create the index:

<?php
  
require("includes/common.php");
  
$sql "CREATE INDEX ean ON `".$config_databaseTablePrefix."products` (ean)";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

With that in place, edit the plugin file pto_product.php and look for the following code at line 17:

  $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."products` WHERE normalised_name = '".$wpdb->escape($pto_product)."' ORDER BY price";

...and REPLACE with:

  $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."products` WHERE normalised_name = '".$wpdb->escape($pto_product)."' OR ean = '".$wpdb->escape($pto_product)."' ORDER BY price";

You will then be able to use an EAN value in the products / prices shortcodes in place of a product name...

Cheers,
David.
--
PriceTapestry.com

Submitted by sanniep on Tue, 2017-01-24 19:50

Awesome! I will give it a go, thanks