Hi,
I'm looking for a way to use some shortcode or other code to view only lowest price by name.
I have viausl composer sidebar and it takes my top/latest post and i want to add the lowest price to each one.
If it's not possbile i would like to know how to show in search results only posts/pages that include price comparison and not all imported items.
Thank you!
Thanks David.
I'm getting table for some reason and not the price only.
Hi,
Sorry about that - I missed out the break statement in the replacement - corrected above, and then double check that you are using lowest instead of prices shortcode e.g.
[pto lowest="Product Name"]
Cheers,
David.
--
PriceTapestry.com
Hi there,
Sorry to break into this one, but i want to do the same for some extra fields which i created in the database. The extra fields are per_stuk (price a piece) and soort (subname).
I try to do the following:
case "lowest":
global $config_currencyHTML;
$sql = "SELECT per_stuk FROM `".$pto_config_databaseTablePrefix."products`
WHERE soort = '".$wpdb->escape($v)."' ORDER BY per_stuk LIMIT 1";
if ($wpdb->query($sql))
{
$html .= $config_currencyHTML.$row->price;
}
break;
case "search"
And the shortcode: [pto lowest="Soort Name"]
If i try a query in my database it works fine:
SELECT per_stuk FROM `pt_products` WHERE soort = 'DryNites' ORDER BY price Limit 1
Thanx in advance!
Hello knhans,
Although you're SELECT'ing per_stuk the display code is still using price - so this line;
$html .= $config_currencyHTML.$row->price;
...should be:
$html .= $config_currencyHTML.$row->per_stuk;
...that should be all it is...
Cheers,
David.
--
PriceTapestry.com
Hmm i had it like that, guess i copied the wrong code in here.
But iam still dont get anything, do you have any other suggestions?
Hi,
Sorry about that - have a go with the following replacement - the above code wasn't using the return variable of $wpdb but this should do the trick;
case "lowest":
global $pto_config_currencyHTML;
$sql = "SELECT per_stuk FROM `".$pto_config_databaseTablePrefix."products`
WHERE soort = '".esc_sql($v)."' ORDER BY per_stuk LIMIT 1";
if ($wpdb->query($sql))
{
$html .= $pto_config_currencyHTML.$wpdb->last_result[0]->per_stuk;
}
break;
case "search"
(also updated to esc_sql() from deprecated $wpdb->escape()...)
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Ah super thank you!
its missing a :
in the end but it working now!
case "lowest":
global $pto_config_currencyHTML;
$sql = "SELECT per_stuk FROM `".$pto_config_databaseTablePrefix."products`
WHERE soort = '".esc_sql($v)."' ORDER BY per_stuk LIMIT 1";
if ($wpdb->query($sql))
{
$html .= $pto_config_currencyHTML.$wpdb->last_result[0]->per_stuk;
}
break;
case "search":
Hello Elior and welcome to the forum!
To add a [pto lowest="Product Name"] shortcode, edit the plugin file pto.php and look for the following code at line 450:
case "search":
...and REPLACE with:
case "lowest":
global $config_currencyHTML;
$sql = "SELECT price FROM `".$pto_config_databaseTablePrefix."products`
WHERE name = '".$wpdb->escape($v)."' ORDER BY price LIMIT 1";
if ($wpdb->query($sql))
{
$html .= $config_currencyHTML.$row->price;
}
break;
case "search":
Hope this helps!
Cheers,
David.
--
PriceTapestry.com