MrGettingRatherFrustrated Posted July 14, 2021 Share Posted July 14, 2021 (edited) Hi all, Hopefully someone has encountered his before I am using a custom product page and template, I am succesfully retrieving all the product and pricing information however have a glitch for prices of -1 Some products have recurring costs monthly or annually and others annually or triennially Displaying all the price options on the product details page works with the biiling cycle which isnt available returing the value in the DB which is -1 The problem is that I obviously dont wnt the unsupported billing cycle and -1 value rendered on the page so used if statements in the template but whatever I do the match/doesn't match criteria doesnt appear to work I am using the following in the PHP page to get the data $getproduct_price = Capsule::table('tblpricing')->where('type','product')->where('relid',$pid)->where('currency',$currencyId)->first(); $monthlyprice = formatCurrency($getproduct_price->monthly, $currencyId); $annuallyprice = formatCurrency($getproduct_price->annually, $currencyId); $trienniallyprice = formatCurrency($getproduct_price->triennially, $currencyId); and the following in the template {if ($monthlyprice > '0')} <span class="price">{$monthlyprice}</span> {$LANG.orderpaymenttermmonthly} {$LANG.truffiere.VatOnOff}<br> {/if} {if ($annuallyprice > '0')} <span class="price">{$annuallyprice}</span> {$LANG.orderpaymenttermannually} {$LANG.truffiere.VatOnOff}<br> {/if} {if ($trienniallyprice > '0')} <span class="price">{$trienniallyprice}</span> {$LANG.truffiere.orderpaymentterm.Triennially} {$LANG.truffiere.VatOnOff}<br> {/if} I have tried numerous varations ie for both match or doesnt match the criteria such as < '0' !> '0' and = '-1' But none of them seem to work against the negative value Any ideas or particularly soutions gratefully accepted! Edited July 14, 2021 by MrGettingRatherFrustrated 0 Quote Link to comment Share on other sites More sharing options...
bear Posted July 14, 2021 Share Posted July 14, 2021 Perhaps try the negation? {if ($monthlyprice != '-1')} 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 14, 2021 Share Posted July 14, 2021 30 minutes ago, MrGettingRatherFrustrated said: Any ideas or particularly solutions gratefully accepted! if I leave the sanctity of my self-imposed mute voyeur mode for just a second, you're going to be hitting three problems. by the time $monthlyprice is accessed by the conditional code in the if statement, it's going to be have been price formatted, e.g it's not going to be -1, it's going to be £-1.00 or €-1.00 etc. if $monthlyprice is price formatted, then you should be able to do {if ($monthlyprice->toNumeric() != '-1.00')} in your conditional statement. what I would do is to only create $monthlyprice if $getproduct_price->monthly is not -1, e.g you move the conditional logic to the php and then, in the template, all you have to check is whether $monthlyprice exists and if so, output accordingly... and so on with the other two pricing options. and with that, I return the gaffer tape over my mouth. 🤐🙂 2 Quote Link to comment Share on other sites More sharing options...
bear Posted July 14, 2021 Share Posted July 14, 2021 12 minutes ago, brian! said: and with that, I return the gaffer tape over my mouth Need to check my knots, since you were able to get your hands free....:P 0 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted July 14, 2021 Author Share Posted July 14, 2021 1 hour ago, brian! said: if I leave the sanctity of my self-imposed mute voyeur mode for just a second, you're going to be hitting three problems. by the time $monthlyprice is accessed by the conditional code in the if statement, it's going to be have been price formatted, e.g it's not going to be -1, it's going to be £-1.00 or €-1.00 etc. if $monthlyprice is price formatted, then you should be able to do {if ($monthlyprice->toNumeric() != '-1.00')} in your conditional statement. what I would do is to only create $monthlyprice if $getproduct_price->monthly is not -1, e.g you move the conditional logic to the php and then, in the template, all you have to check is whether $monthlyprice exists and if so, output accordingly... and so on with the other two pricing options. and with that, I return the gaffer tape over my mouth. 🤐🙂 As always Brian thank you You are quite correct and using toNumeric as you showed above gives the desired result I have changed in the template for now to achieve the desired result but will take your advice and refine the PHP and template Once more - 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 23, 2021 Share Posted July 23, 2021 On 14/07/2021 at 14:09, bear said: Need to check my knots, since you were able to get your hands free....:P the hands were not the problem... I suspect my ankles will never be the same again! 😱🔨 i've only come back today cos I got sent a PM that needs replying to. 🤐 while i'm here, i'll briefly reply to a few unanswered threads, but I doubt i'll login again this month.... i'm really enjoying no longer receiving/reading the threads emails (or even launching / thinking about WHMCS any more!) and getting on with more important things. 🏖️🍦 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.