DBH Web Posted January 28, 2016 Share Posted January 28, 2016 Ok what I would like to do is (as the title says) Display annual pricing only on one cart template. I have products that I sell that are paid monthly, annually and bi annually and by ticking the "Monthly Pricing Breakdown" in the ordering tab they display how they should, however I also have other products that can only be purchased annually but because I have this option ticked they display as monthly. So my question is: lets say I use the Standard Cart as the template and of course make a copy and name it something else so I can modify it, what would the code be to display only the full annual price on that cart overriding the default "Monthly Pricing Breakdown" ? Thanks to any and all for advice to come. Oh P.S. I did search the forums and Google but could only come up with the reverse to what I want. 0 Quote Link to comment Share on other sites More sharing options...
DBH Web Posted January 28, 2016 Author Share Posted January 28, 2016 (edited) OK I found this on line 65 of the products.tpl of the Standard Cart. I have tried changing monthly to annually but that makes no difference. <div class="product-pricing" id="product{$product@iteration}-price"> {if $product.bid} {$LANG.bundledeal}<br /> {if $product.displayprice} <span class="price">{$product.displayprice}</span> {/if} {else} {if $product.pricing.hasconfigoptions} {$LANG.startingfrom} <br /> {/if} <span class="price">{$product.pricing.minprice.price}</span> <br /> {if $product.pricing.minprice.cycle eq "monthly"} {$LANG.orderpaymenttermmonthly} {elseif $product.pricing.minprice.cycle eq "quarterly"} {$LANG.orderpaymenttermquarterly} {elseif $product.pricing.minprice.cycle eq "semiannually"} {$LANG.orderpaymenttermsemiannually} {elseif $product.pricing.minprice.cycle eq "annually"} {$LANG.orderpaymenttermannually} {elseif $product.pricing.minprice.cycle eq "biennially"} {$LANG.orderpaymenttermbiennially} {elseif $product.pricing.minprice.cycle eq "triennially"} {$LANG.orderpaymenttermtriennially} {/if} {/if} </div> Edited January 28, 2016 by DBH Web 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 28, 2016 Share Posted January 28, 2016 you got the right section - but the line you have to play with is.... <span class="price">{$product.pricing.minprice.price}</span> to show the annual price instead, you'll need to use... <span class="price">{$currency.prefix}{$product.pricing.rawpricing.annually}{$currency.suffix}</span> and if you only want to do it for certain products, you can use the PID value(s) to identify them... <span class="price">{if $product.pid eq '49'}{$currency.prefix}{$product.pricing.rawpricing.annually}{$currency.suffix}{else}{$product.pricing.minprice.price}{/if}</span> so for product 49, it will show the annual price; for all other products, it will show the monthly breakdown price. obviously, in the above code, i'm not doing any checks to see if product 49 has an annual price - but you can decide whether this is required for your needs. 0 Quote Link to comment Share on other sites More sharing options...
Amcom Posted January 31, 2016 Share Posted January 31, 2016 and if you only want to do it for certain products, you can use the PID value(s) to identify them... <span class="price">{if $product.pid eq '49'}{$currency.prefix}{$product.pricing.rawpricing.annually}{$currency.suffix}{else}{$product.pricing.minprice.price}{/if}</span> so for product 49, it will show the annual price; for all other products, it will show the monthly breakdown price. I see {if $product.pid eq '49'} however I have 3 products that are annual, how do I add the other 2 to this code? I have pip 11, pid 12 & pid 13 Thanks, 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 31, 2016 Share Posted January 31, 2016 I see {if $product.pid eq '49'} however I have 3 products that are annual, how do I add the other 2 to this code? I have pip 11, pid 12 & pid 13 there are a few ways to do this, depending on how many products you have - you can use OR or create an array of product PIDs and use that... so if you wanted to use OR... <span class="price">{if $product.pid eq '11' OR $product.pid eq '12' OR $product.pid eq '13'}{$currency.prefix}{$product.pricing.rawpricing.annually}{$currency.suffix}{else}{$product.pricing.minprice.price}{/if}</span> I think there is a limit to how many ORs you can have in the statement, but it's something ridiculously high (many tens), so not worth worrying about in this case. because your PIDs are also sequential, you could check if their values are inclusively between 11 and 13 - but then that would fail if you later add a pid out of the sequence... the other way would be to define an array of PIDs and then check if the current PID is in that array. so, at the top of products.tpl, after the include, add the array definition... {include file="orderforms/standard_cart/common.tpl"} {$annualproducts = ['11','12','13']} and then modify the pricing line to be... <span class="price">{if $product.pid|in_array:$annualproducts}{$currency.prefix}{$product.pricing.rawpricing.annually}{$currency.suffix}{else}{$product.pricing.minprice.price}{/if}</span> so, for these three products, it should display the annual price - for other products, it will show the monthly breakdown price. btw - the above uses Smarty v3, so will work with v6, but will likely fail if you try it with v5 or earlier... and the array list doesn't need to be in any numeric order. 0 Quote Link to comment Share on other sites More sharing options...
Amcom Posted January 31, 2016 Share Posted January 31, 2016 Thanks Brian just what I needed. I used the ( OR ) statement because I only have 3 annual. 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.