Jump to content

Display total price on product price without any options selected?


-M-

Recommended Posts

Hi guys,

 

I have a quick question. Currently I am using the following variable

 

$product.pricing.cycles.annually

 

To display the lowest possible prices for our products. This works, however it will always list the price with the selected (default) 'Configurable Options'.

In other words; the default options actually increase the 'lowest' price. Obviously I can change this, however this is not something I want to do.

 

I want to display the lowest possible price, without taking the 'Configurable Options' into consideration.

 

I hope this makes any sense and I don't know if it's even possible?

 

Thank you in advance for your help!

 

Regards

 

//edit

 

Maybe a better wordt for what I am trying to display is the base price of a product. So without any options, just the base price.

I did try to use {debug} but all prices I could find in there are the prices included with some/several default options selected, which actually increases the price. Which I don't want.

As mentioned above I could change the default option to the one which doesn't add up to price, however that's something I don't want to happen. Kinda 'catch 22'-scenario (if I am not mistaken).

Edited by MvdL1979
Added information.
Link to comment
Share on other sites

if the variable/value you want doesn't exist, then you're left with pulling it from the database... either by writing a hook and passing the value back to a Smarty variable or array - or using a data feed.

 

as the solution already exists, i'd be tempted to just use a data feed -

 

productsinfo.php?pid=1&get=price&billingcycle=annually

 

that would give you a base price without the additional configurable option prices being added to it.

Link to comment
Share on other sites

Hi brian!,

 

Uhmz... Though a data feed might be an idea, I can already think of a few issues with it when using it on the products.tpl page.

 

Issue #1

We have 12 products on this products.tpl page. This would mean I have to make a call to the data feed several times (12 times to be more precise), right?

For example:

<script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=annually">
<script language="javascript" src="feeds/productsinfo.php?pid=2&get=price&billingcycle=annually">
<script language="javascript" src="feeds/productsinfo.php?pid=3&get=price&billingcycle=annually">
etc.

 

This would slow down the page considerably, right?

 

Issue #2

If we would add a new product, this would mean we, or better said I, have to add the new product also by hand into this products.tpl template, right?

 

Maybe I am mistaken here, but this is what comes to mind after reading your reply.

 

Regards

Link to comment
Share on other sites

Uhmz... Though a data feed might be an idea, I can already think of a few issues with it when using it on the products.tpl page.

 

Issue #1

We have 12 products on this products.tpl page. This would mean I have to make a call to the data feed several times (12 times to be more precise), right?

For example:

<script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=annually">
<script language="javascript" src="feeds/productsinfo.php?pid=2&get=price&billingcycle=annually">
<script language="javascript" src="feeds/productsinfo.php?pid=3&get=price&billingcycle=annually">
etc.

 

This would slow down the page considerably, right?

it shouldn't be too bad... there are only two products in the v6.3.1 dev and I can't spot any difference using the feeds... try it and see.

 

Issue #2

If we would add a new product, this would mean we, or better said I, have to add the new product also by hand into this products.tpl template, right?

Maybe I am mistaken here, but this is what comes to mind after reading your reply.

you shouldn't need to do anything manually - you'll just need to use Smarty variables in the feed url, e.g change in products.tpl...

 

<span class="price">{$product.pricing.minprice.price}</span>

to...

<span class="price"><script language="javascript" src="feeds/productsinfo.php?pid={$product.pid}&get=price&billingcycle={$product.pricing.minprice.cycle}"></script></span>

that way, the feed will take the variables it needs from existing Smarty variables. :idea:

Link to comment
Share on other sites

it shouldn't be too bad... there are only two products in the v6.3.1 dev and I can't spot any difference using the feeds... try it and see.

 

I will give it a go, currently still testing it. Or better said fine-tuning, see below. :)

 

 

you shouldn't need to do anything manually - you'll just need to use Smarty variables in the feed url, e.g change in products.tpl...

 

<span class="price">{$product.pricing.minprice.price}</span>

to...

<span class="price"><script language="javascript" src="feeds/productsinfo.php?pid={$product.pid}&get=price&billingcycle={$product.pricing.minprice.cycle}"></script></span>

that way, the feed will take the variables it needs from existing Smarty variables. :idea:

 

Man, I am dumb... Didn't know you could also use smarty variables in there. Well, not the way you showed me.

Thanks for pointing it out. :)

 

As mentioned above, I am fine-tuning it, because the result was still incorrect.

Before making changes I created a duplicate of productsinfo.php and called it dps.php (so it will not get overwritten in case of future updates).

 

Then I changed this:

<span class="price"><script language="javascript" src="feeds/dps.php?pid={$product.pid}&get=price&billingcycle={$product.pricing.minprice.cycle}"></script></span>

 

into this:

<span class="price"><script language="javascript" src="feeds/dps.php?pid={$product.pid}&get=price&billingcycle=annually"></script></span>  

 

The reason is, is that with payment annually they get a discount. This amount was shown with the previous code. No clue why, but the numbers were off a bit.

Anyways, using the bove fixed this, but I also had to change one line in dps.php (previously productsinfo.php).

 

I changed dps.php ( line #88 ) from this:

   $price = $data[$billingCycle];

 

into this:

   $price = $data[$billingCycle]/12;

 

Now the displayed price is finally correct!

 

I am just making sure, if what I did make sense at all?

 

Thank you once again!

 

Regards

Link to comment
Share on other sites

it makes sense if you're intending to show the monthly equivalent price for an annual product.

 

So, for the first time since a very looooooooooooong time, I actually did something good. :)

Yeah, the annually price is a discounted price, so therefor I want to show that instead of quarterly price. But the amount should be divided by 12 so it will show the discounted price per month. :)

 

Okay, back to the fact the script is slowing down the page (a bit). In my humble opinion, it does slow down the website a bit, but probably because I call the javascript code 5 times in the whole products.tpl page. This is because I am sorting the displayed products (as in RAID, non-RAID, AMD and Intel).

 

Is there a simple way to create some kind of variable or piece of code where you put the the javascript at the top / end of the page and only call it once?

 

This is the javascript I am using now:

<script language="javascript" src="feeds/dps.php?pid={$product.pid}&get=price&billingcycle=annually"></script>

 

This string is called 5 times on the whole page. I think there is a better way to call the string only once (at the top or at the end).

And yes, the string is exactly the same on all 5 occasions.

 

I will try a to show my very professional coding skills as what I mean:

 

At top or at the end (don't know what's best):

$woohoo = <script language="javascript" src="feeds/dps.php?pid={$product.pid}&get=price&billingcycle=annually"></script>

 

Then replace the following code:

<span class="price"><script language="javascript" src="feeds/dps.php?pid={$product.pid}&get=price&billingcycle=annually"></script></span>

 

Five (5) times with:

<span class="price">$woohoo</span>

 

Is this possible? And would this reduce the load?

I think so, because it's only called once instead of 5 times, right?

 

Regards

Edited by MvdL1979
Correction: Actually it's 5 times, instead of 4 times.
Link to comment
Share on other sites

So, for the first time since a very looooooooooooong time, I actually did something good. :)

yes, but don't count your chickens yet...

 

Yeah, the annually price is a discounted price, so therefore I want to show that instead of quarterly price. But the amount should be divided by 12 so it will show the discounted price per month. :)

Okay, back to the fact the script is slowing down the page (a bit). In my humble opinion, it does slow down the website a bit, but probably because I call the javascript code 5 times in the whole products.tpl page. This is because I am sorting the displayed products (as in RAID, non-RAID, AMD and Intel).

oh i'd forgotten all about those {if} statements and string searches.... or tried to forget them at least.

 

Is there a simple way to create some kind of variable or piece of code where you put the the javascript at the top / end of the page and only call it once?

can I say yes and no to this?

 

the real answer to your question is no - the feeds work by making specific queries to the database and outputting the result... so you're effectively making 5 separate queries to the database for your products page.

 

This string is called 5 times on the whole page. I think there is a better way to call the string only once (at the top or at the end).

And yes, the string is exactly the same on all 5 occasions.

I will try a to show my very professional coding skills as what I mean:

Is this possible? And would this reduce the load?

I think so, because it's only called once instead of 5 times, right?

it wouldn't work for a number of reasons... not the least of which will be that $product.pid will never change where you put it in your code... when the feed call is inside the product foreach loop, it's value will be relevant for each product... do it anywhere outside the loop, and that value won't change...

 

you can't really use feeds to create variables... technically, you probably can - and I suppose you could get it to output all five values into a variable in Smarty and then split it for the output in the loop, but that's seems a weird and complicated way to do this... if you're going to want to use variables, you might as well use an action hook.

 

so if you think the feed is too slow, then you'll have to use the alternate method - an action hook - e.g querying the database for prices in the current group and passing it back to the template as an array/variable.

Link to comment
Share on other sites

yes, but don't count your chickens yet...

 

* shrugs * :P

 

 

 

oh i'd forgotten all about those {if} statements and string searches.... or tried to forget them at least.

 

can I say yes and no to this?

 

the real answer to your question is no - the feeds work by making specific queries to the database and outputting the result... so you're effectively making 5 separate queries to the database for your products page.

 

it wouldn't work for a number of reasons... not the least of which will be that $product.pid will never change where you put it in your code... when the feed call is inside the product foreach loop, it's value will be relevant for each product... do it anywhere outside the loop, and that value won't change...

 

you can't really use feeds to create variables... technically, you probably can - and I suppose you could get it to output all five values into a variable in Smarty and then split it for the output in the loop, but that's seems a weird and complicated way to do this... if you're going to want to use variables, you might as well use an action hook.

 

so if you think the feed is too slow, then you'll have to use the alternate method - an action hook - e.g querying the database for prices in the current group and passing it back to the template as an array/variable.

 

Okay, well it was worth to ask though. :)

Thanks for explaining it nevertheless obviously. Your explanation was quite clear. I will leave it as it is. If it really does get slower, I will ask someone to create an action hook for it though. But for the time being it should suffice. It's not like it is terribly slow or anything, but I thought there would have been a better way, instead of calling the script 5 times. Maybe I can make the script smaller or something, but I will look into this myself.

 

 

 

(since you replied quicker than I expected, I combined the post below with my answer above)

 

I want to be able to do the same with a different product, however this product uses a different template, where it's not as easy to use the javascript string. :|

 

The template I am using for this product is the 'Cloud Slider' template. Is it possible to include the data feed there as well, or is this not possible?

If this is not possible, or maybe easier, is there a way to deduct a fixed amount of the displayed price? I need it to be 0.54 Euro less. :S

 

I skimmed through the code at the bottom of products.tpl (from Cloud Slider template) and this is the string which is showing the price:

 

displayPrice": "{$product.pricing.minprice.price}

 

Is there a way to have the amount which is being displayed with that string deducted with 0.54 Euro?

That would solve things as well for this template.

Edited by MvdL1979
Combined posts. To keep it clean.
Link to comment
Share on other sites

Okay, well it was worth to ask though. :)

Thanks for explaining it nevertheless obviously. Your explanation was quite clear. I will leave it as it is. If it really does get slower, I will ask someone to create an action hook for it though. But for the time being it should suffice. It's not like it is terribly slow or anything, but I thought there would have been a better way, instead of calling the script 5 times. Maybe I can make the script smaller or something, but I will look into this myself.

I wouldn't have thought it would crawl unless there were a lot of feed requests, e.g double-figure numbers...

 

I want to be able to do the same with a different product, however this product uses a different template, where it's not as easy to use the javascript string. :|

The template I am using for this product is the 'Cloud Slider' template. Is it possible to include the data feed there as well, or is this not possible?

i'm sure it'd be possible, though might need a little bit of experimentation to get it to parse correctly.

 

If this is not possible, or maybe easier, is there a way to deduct a fixed amount of the displayed price? I need it to be 0.54 Euro less. :S

I skimmed through the code at the bottom of products.tpl (from Cloud Slider template) and this is the string which is showing the price:

displayPrice": "{$product.pricing.minprice.price}

 

Is there a way to have the amount which is being displayed with that string deducted with 0.54 Euro?

That would solve things as well for this template.

you could do this..

 

"displayPrice": "{$currency.prefix}{($product.pricing.minprice.price|replace:$currency.prefix:''|replace:$currency.suffix:'' - 0.54)|number_format:2}{$currency.suffix}",

what this basically does is remove the currency prefix and suffix from the variable (e.g € and EUR) if they exist; you're then effectively left with a number that you can perform your calculations on; set the result to 2 decimal places (only really needed if result is a whole number, e.g 10 and not 10.01)... and then you re-add the currency prefix and suffix.

 

you should be able to use the Smarty code on any of the templates instead of using the feed to adjust the price. :idea:

Link to comment
Share on other sites

I wouldn't have thought it would crawl unless there were a lot of feed requests, e.g double-figure numbers...

 

No worries then. I thought it was something easy to do so. I will ignore it for the time being. I added a loader screen, something like "fetching servers". :)

 

 

 

i'm sure it'd be possible, though might need a little bit of experimentation to get it to parse correctly.

 

It's kinda annoying that several templates are different or require a different approach. Well, to be more precise, this is the only "other" template I use.

And the previous way doesn't for it, because it's different. :P

 

 

 

you could do this..

 

"displayPrice": "{$currency.prefix}{($product.pricing.minprice.price|replace:$currency.prefix:''|replace:$currency.suffix:'' - 0.54)|number_format:2}{$currency.suffix}",

what this basically does is remove the currency prefix and suffix from the variable (e.g € and EUR) if they exist; you're then effectively left with a number that you can perform your calculations on; set the result to 2 decimal places (only really needed if result is a whole number, e.g 10 and not 10.01)... and then you re-add the currency prefix and suffix.

 

It sounds to me that you don't approve of this method? Or am I mistaken? :|

(didn't have my 3rd coffee yet, so I could be mistaken) :P

 

 

 

you should be able to use the Smarty code on any of the templates instead of using the feed to adjust the price. :idea:

 

Well, I considered that, but I don't know how to use the datafeed with this template.

That's the whole problem and also why I created the previous (last) post. It's completely different and most is already in javascript. :P

 

 

 

//update...

 

Well the code didn't work, well kinda. Instead of the expected amount of 5.00 I got 4.46. I am getting the impression it deducted 0.54 twice.

I also tried to use the data feed in there, but the only thing I am getting is product ID not found, so apparently it doesn't work with this template.... :'(

 

//edit

 

Bleh... I guess there isn't an easier way to replace this:

 

"displayPrice": "{$product.pricing.minprice.price}",

 

With the data feed string, like:

<script language="javascript" src="feeds/productsinfo.php?pid={$product.pid}&get=price&billingcycle={$product.pricing.minprice.cycle}"></script>

Placing it in or around the where the price should appear doesn't work, it will display "Product ID Not Found"

Edited by MvdL1979
Update post.
Link to comment
Share on other sites

It's kinda annoying that several templates are different or require a different approach. Well, to be more precise, this is the only "other" template I use.

And the previous way doesn't for it, because it's different. :P

I was never really impressed by Cloud Slider when it was first released last year... to use an English expression, it looked a little 'naff' to me - given a cup of tea and a clear afternoon, i'd be disappointed if I couldn't make something better than that. :roll:

 

It sounds to me that you don't approve of this method? Or am I mistaken? :|

(didn't have my 3rd coffee yet, so I could be mistaken) :P

you're mistaken - it would be quicker than calling a feed and I rarely object to using Smarty! :idea:

 

given what I know about your site, I would rank the solutions in this order:

 

1. data feed.

2. Smarty calculation.

3. action hook.

 

most users would probably prefer the action hook solution, but as you've modified your templates so much, what's a little more Smarty code going to matter?!? unless you were using a hook to modify an existing pricing variable, you'd have to modify the template anyway to call the new variable - so given that, you might as well use Smarty... especially if you have concerns about the data feeds slowing down the site.

 

Well, I considered that, but I don't know how to use the datafeed with this template.

That's the whole problem and also why I created the previous (last) post. It's completely different and most is already in javascript. :P

I never tried it, but you could try your original idea of assigning a variable to use the data feed result and then use that Smarty variable in the javascript... though frankly, I wouldn't bother as it's probably easier to manipulate the Smarty variables and use them.

 

Well the code didn't work, well kinda. Instead of the expected amount of 5.00 I got 4.46. I am getting the impression it deducted 0.54 twice.

I also tried to use the data feed in there, but the only thing I am getting is product ID not found, so apparently it doesn't work with this template.... :'(

I tried the Smarty code locally before posting - on both Standard_cart (where I wrote the formula) and then in Cloud Slider - it works in both. :idea:

 

one thing that you might want to check is if you're using the right variable?

 

{$product.pricing.minprice.price}

if your product has both monthly and annual pricing, then this variable would use the monthly price.. so perhaps it is deducting 0.54 from the wrong price ?

Link to comment
Share on other sites

I was never really impressed by Cloud Slider when it was first released last year... to use an English expression, it looked a little 'naff' to me - given a cup of tea and a clear afternoon, i'd be disappointed if I couldn't make something better than that. :roll:

 

Actually I did modify it. :)

And it looks much better now.

 

you're mistaken - it would be quicker than calling a feed and I rarely object to using Smarty! :idea:

 

given what I know about your site, I would rank the solutions in this order:

 

1. data feed.

2. Smarty calculation.

3. action hook.

 

most users would probably prefer the action hook solution, but as you've modified your templates so much, what's a little more Smarty code going to matter?!? unless you were using a hook to modify an existing pricing variable, you'd have to modify the template anyway to call the new variable - so given that, you might as well use Smarty... especially if you have concerns about the data feeds slowing down the site.

 

Really didn't know that 'Data Feed' came in at first position. Didn't even know of it's existence till a week ago. :P

 

 

I never tried it, but you could try your original idea of assigning a variable to use the data feed result and then use that Smarty variable in the javascript... though frankly, I wouldn't bother as it's probably easier to manipulate the Smarty variables and use them.

 

Okay let's skip that idea then. :)

 

 

I tried the Smarty code locally before posting - on both Standard_cart (where I wrote the formula) and then in Cloud Slider - it works in both. :idea:

 

one thing that you might want to check is if you're using the right variable?

 

{$product.pricing.minprice.price}

if your product has both monthly and annual pricing, then this variable would use the monthly price.. so perhaps it is deducting 0.54 from the wrong price ?

 

Really weird... I will try again, since I put everything back as it was.

 

I change this part of code:

var allProducts = {
   {foreach $products as $num => $product}
       "{$num}": {
           "name": "{$product.name}",
           "desc": "{$product.featuresdesc|nl2br|trim}",
           {if isset($product.pid)}
               "pid": "{$product.pid}",
               "displayPrice": "{$product.pricing.minprice.price}",
               "displayCycle": "{$product.pricing.minprice.cycle}",
           {else}
               "bid": "{$product.bid}",
               "displayPrice": "{$product.displayprice}",
               "displayCycle": "",
           {/if}
           "features": {
               {foreach $product.features as $k => $feature}
                   "{$k}": "{$feature}",
               {/foreach}
           },
           "featurePercentages": {
               {foreach $featurePercentages as $featureKey => $feature}
                   {if isset($feature.$num)}
                       "{$featureKey}": "{$feature.$num}",
                   {/if}
               {/foreach}
           }
       },
   {/foreach}
};

 

into this:

 

var allProducts = {
   {foreach $products as $num => $product}
       "{$num}": {
           "name": "{$product.name}",
           "desc": "{$product.featuresdesc|nl2br|trim}",
           {if isset($product.pid)}
               "pid": "{$product.pid}",
               //"displayPrice": "{$product.pricing.minprice.price}",
			"displayPrice": "{$currency.prefix}{($product.pricing.minprice.price|replace:$currency.prefix:''|replace:$currency.suffix:'' - 0.54)|number_format:2}{$currency.suffix}",  
               "displayCycle": "{$product.pricing.minprice.cycle}",
           {else}
               "bid": "{$product.bid}",
               "displayPrice": "{$product.displayprice}",
               "displayCycle": "",
           {/if}
           "features": {
               {foreach $product.features as $k => $feature}
                   "{$k}": "{$feature}",
               {/foreach}
           },
           "featurePercentages": {
               {foreach $featurePercentages as $featureKey => $feature}
                   {if isset($feature.$num)}
                       "{$featureKey}": "{$feature.$num}",
                   {/if}
               {/foreach}
           }
       },
   {/foreach}
};

 

After saving and uploading the file it will display the price as: 4.46 Euro (instead of 5.00 Euro).

Before the changes it was 5.54 Euro. So it deducted twice the necessary amount (total deducation: 1.08 Euro).

 

So no clue on what I am doing wrong here. I think I made the change in the correct place?

 

Regards

Link to comment
Share on other sites

Actually I did modify it. :)

And it looks much better now.

:idea:

 

Really didn't know that 'Data Feed' came in at first position. Didn't even know of it's existence till a week ago. :P

I was being lazy as it was the easiest solution that already existed in WHMCS.

 

Really weird... I will try again, since I put everything back as it was.

After saving and uploading the file it will display the price as: 4.46 Euro (instead of 5.00 Euro).

Before the changes it was 5.54 Euro. So it deducted twice the necessary amount (total deducation: 1.08 Euro).

So no clue on what I am doing wrong here. I think I made the change in the correct place?

as you say... weird. :twisted:

 

it looks like you're putting it in the right place, but it fails for you and works for me. :?:

 

this is what i'm seeing - before and after with 1.23 (the price of the config option removed)... change to 0.54 for your needs.

 

uDOeqnK.png

u4iDbLn.png

 

"displayPrice": "{$currency.prefix}{($product.pricing.minprice.price|replace:$currency.prefix:''|replace:$currency.suffix:'' - 1.23)|number_format:2}{$currency.suffix}",

but this is using the monthly price (the lowest cycle price), so I know i'm using the correct variable... i'm still unsure if you're trying to use annual prices for this product and/or if you're dividing them by 12 to make it a monthly price :?:

 

say if you are trying to show annual pricing by default, you could use the rawpricing values instead - that would avoid the need to remove the currency details...

 

                "displayPrice": "{$currency.prefix}{($product.pricing.rawpricing.annually - 1.23)|number_format:2}{$currency.suffix}",
               "displayCycle": "{$LANG.orderpaymenttermannually|strtolower}",

or if you wanted to convert the annual price to a monthly breakdown price... though watch out for any rounding errors.

 

                "displayPrice": "{$currency.prefix}{(($product.pricing.rawpricing.annually - 1.23)/12)|number_format:2}{$currency.suffix}",
               "displayCycle": "{$LANG.orderpaymenttermmonthly|strtolower}",

Link to comment
Share on other sites

:idea:

 

I didn't like it either, BUT I did like the idea behind. Later on the other slider was released, but probably it's more of the same in words of coding. Didn't even take a look at it to be honest.

 

 

 

I was being lazy as it was the easiest solution that already existed in WHMCS.

 

So do I now. :)

 

 

 

as you say... weird. :twisted:

it looks like you're putting it in the right place, but it fails for you and works for me. :?:

 

Yeah really strange. At first I thought I made a mistake, but after redoing it twice... I was pretty sure I was adding it in the correct location, otherwise it wouldn't show any changes either imho.

 

 

 

this is what i'm seeing - before and after with 1.23 (the price of the config option removed)... change to 0.54 for your needs.

"displayPrice": "{$currency.prefix}{($product.pricing.minprice.price|replace:$currency.prefix:''|replace:$currency.suffix:'' - 1.23)|number_format:2}{$currency.suffix}",

but this is using the monthly price (the lowest cycle price), so I know i'm using the correct variable... i'm still unsure if you're trying to use annual prices for this product and/or if you're dividing them by 12 to make it a monthly price :?:

 

Yeah, it clearly looks like it's working for you. I don't understand why it's not working for me though.

Maybe it's because of the "Configurable options"...? I don't think so, but I am getting desperate with this. lol.

 

Oh please ignore the price dividing by 12. That was for a different product AND template (servers). That one is working fine!

It's just this stupid template which is being a pain....

 

 

 

say if you are trying to show annual pricing by default, you could use the rawpricing values instead - that would avoid the need to remove the currency details...

 

                "displayPrice": "{$currency.prefix}{($product.pricing.rawpricing.annually - 1.23)|number_format:2}{$currency.suffix}",
               "displayCycle": "{$LANG.orderpaymenttermannually|strtolower}",

or if you wanted to convert the annual price to a monthly breakdown price... though watch out for any rounding errors.

 

                "displayPrice": "{$currency.prefix}{(($product.pricing.rawpricing.annually - 1.23)/12)|number_format:2}{$currency.suffix}",
               "displayCycle": "{$LANG.orderpaymenttermmonthly|strtolower}",

 

Anyways, I decided to give the following piece of code a go, based on what you have given me.

 

First I tried this:

"displayPrice": "{$currency.prefix}{($product.pricing.rawpricing.annually - 0.00)|number_format:2}{$currency.suffix}",

 

Just to check what price I would get, which is: 66.48 EUR (which is base price + the default option enabled).

Though it's not the lowest price I want to show, the calculation is correct.

 

When I then use:

"displayPrice": "{$currency.prefix}{($product.pricing.rawpricing.annually - 6.48)|number_format:2}{$currency.suffix}",

 

I get the correct amount, though being annually of: 60.00 Euro (base price without option price included).

 

So far this is all correct, though it's annually.

 

So next I tried:

"displayPrice": "{$currency.prefix}{(($product.pricing.rawpricing.annually - 6.48)/12)|number_format:2}{$currency.suffix}",

 

And I get *drumroll* the price of: 5.00 Euro (this is correct).

 

So, as for the main question, why is this working and the previous code (see below) doesn't work?

 

"displayPrice": "{$currency.prefix}{($product.pricing.minprice.price|replace:$currency.prefix:''|replace:$currency.suffix:'' - 0.54)|number_format:2}{$currency.suffix}",  

 

This outputs some strange amount: 4.46 Euro.

I also tried to enter different amounts in the above code, but the results are not normal. Even when I use 0.00 I get something completely weird. Or better said incorrect prices.

 

So the only piece of code which is working is your latest one:

 

"displayPrice": "{$currency.prefix}{(($product.pricing.rawpricing.annually - 6.48)/12)|number_format:2}{$currency.suffix}",

 

I checked all hostingpackages for that category and the amounts seem correct. I do have to test it a bit more, but I think this solves it.

 

....arghh, I was re-editing my text to make it look more organised and I noticed I typed ignore the /12. Though it actually works?!

Now my head is starting to hurt. :|

 

Regards

 

- - - Updated - - -

 

Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaargh....

 

I give up on this. One hostingpackage doesn't use the configurable option and it shows now a negative amount.

I am gonna call it a day. This ain't fun.

 

I will check again tomorrow. If I cannot find a solution for it, I am gonna ditch this stupid template completely. It's starting to annoy me to much. :|

 

(sorry for the trouble / time brian!)

 

Regards

Edited by MvdL1979
Link to comment
Share on other sites

throw a {debug} into the template and find out what {$product.pricing.minprice.cycle} is - it can't be annual (otherwise the original code would work)... so it must be monthly, quarterly or some other billing cycle.

 

with regards to one package not using a config option, there is a variable within the $product array that is set to true/false depending upon whether the product uses config options, so you might need an {if} statement inside of the javascript to create a Smarty variable based on that value...

 

var allProducts = {
   {foreach $products as $num => $product}
   {if $product.pricing.hasconfigoptions == true}
       {assign deduction '0.54'}
   {else}
       {assign deduction '0'}
   {/if}

       "{$num}": {
           "name": "{$product.name}",
           "desc": "{$product.featuresdesc|nl2br|trim}",
           {if isset($product.pid)}
               "pid": "{$product.pid}",
               "displayPrice": "{$currency.prefix}{(($product.pricing.rawpricing.annually - $deduction)/12)|number_format:2}{$currency.suffix}",
               "displayCycle": "{$product.pricing.minprice.cycle}",
           {else}
               "bid": "{$product.bid}",
               "displayPrice": "{$product.displayprice}",
               "displayCycle": "",
           {/if}
           "features": {
               {foreach $product.features as $k => $feature}
                   "{$k}": "{$feature}",
               {/foreach}
           },
           "featurePercentages": {
               {foreach $featurePercentages as $featureKey => $feature}
                   {if isset($feature.$num)}
                       "{$featureKey}": "{$feature.$num}",
                   {/if}
               {/foreach}
           }
       },
   {/foreach}
};

Edited by brian!
Link to comment
Share on other sites

I will do so tomorrow brian! :)

 

I had enough of this template for one day. I also skimmed through the Universal Slider template.

Seems it's easier to edit? Will investigate that idea tomorrow. * shrugs *

Link to comment
Share on other sites

Hi brian!

 

Well, as promised, I am reporting back.

 

I noticed that there was another hosting package with the same issue. So I decided to try to change the Universal Slider to make it look and feel like my current version of Cloud Slider...

...well to be honest, I was done with that after 2 minutes. Way to much work. It's "very" different.

 

Anyways, I took the coder approach (do I have that at all?). :P

 

You code inspired me to create a workaround for it and I did the following:

 

   {if $product.name == "Hosting Package A" || $product.name == "Hosting Package Q"}
       {assign deduction '0'}
       {else}
       {assign deduction '6.48'}
   {/if}

 

Tested it several times and it works. Finally.

 

This code is correct right? No weird suprises for me at the horizon, right?

 

Regards

Edited by MvdL1979
Fixed formatting...
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated