Product Options - Absolute Value

Does anyone know if there is a way to or if there is an addon out there to show an absolute value of an item in the product’s option’s drop down box?



For example, I’m loading men’s t-shirts and sizes xs - xl are at the listed price. Sizes 2x - 4x are $3.00 more and size 5x - 6x are $5.00 more.



Say the price is $10 for sizes xs - xl. When the customer goes to choose a size, I want them to see:



XS

S

M

L

XL

2X ($13.00)

3X ($13.00)…





I don’t like the (+$3.00) and (+$5.00), I’d rather show the absolute amount if at all possible.





I’m not selling shirts, but what I am looking at setting up has funky numbers like (-2.87), (-3.17), etc. I’m entering the costs in my descriptions so the customer won’t have to try and do the math, although I know that all they have to do is click on the option and it will show in the price, I’d rather it show on the drop down.

I was just working on this myself. Here is the solution:



Enable the “My Changes” add-on.

Create a “my_changes” folder in the /skins/yourskin/customer/addons/ directory.

In that new directory, create a “products” folder.

Now, create a new file called “options_modifiers.override.tpl” and save it in your new /my_changes/products/ directory. Add the following code to this new file:```php

{if $vr.modifier|floatval}{if $product.base_price NE “0.00”}({include file=“common_templates/modifier.tpl” mod_type=$vr.modifier_type mod_value=$vr.modifier+$product.base_price display_sign=false}){/if}{/if} ```

Don’t delete that HTML comment. The CSC hooks system will ignore the file if there isn’t any non-smarty code in the file (weird, I know). You’ll probably have to clear your cache to see this take effect.



This mod also hides the price modifier completely if the item’s base price is $0. I have some situations where I put the total cost of a product variation in the product option. The cart then automatically displays the value from the product option in place of $0. I’m not explaining that clearly, but hopefully you get the idea.



cheers,

Glen

[quote]

Don’t delete that HTML comment. The CSC hooks system will ignore the file if there isn’t any non-smarty code in the file (weird, I know). You’ll probably have to clear your cache to see this take effect.

[/quote]

I’ve never encountered this issue. I have many hooks without smarty code in them… That would be a major bug if that were the case.



The only qualification I know if is that the data in the file (after a trim()) must have some content. I.e. not empty.

Glen, I’m using 2.1.2 and it didn’t work for me.



I made sure the add-on My Changes was active.









I did all my editing in Cpanel file manager



I use the Just skin so I created the my_changes folder in the /skins/Just/customer/addons/ directory







I created the products folder in that folder







I added the options_modifiers.override.tpl file in the products folder







I used the html editor in the Cpanel file manager to edit the code into the tpl file



I got this box before I edited in the code









I clicked on the edit button and added and saved the code











I cleared the admin cache by adding the ?cc to the end of the php in my admin url and also did the ?ct at the end of the php in my admin url.



I went into the product options and deleted the option I had for the item and readded the option







and the variants







I saved everything then saved.



I cleared the browser cache and went to the storefront to check it, but it is still adding the plus and adding to the original price instead of showing absolute price











I’m hoping you can tell me what I have wrong to get this to work.[HTML][/HTML]

Brian,

Your steps look correct. The one thing I can’s see in those screenshots is the permissions settings for the 2 new directories you created and the new .tpl. Try setting those to 777 and check the storefront to see if it worked.

Glen

Tony,

In my tests with this mod, CSC completely ignored my override.tpl unless I added some content outside of the {if}{/if}. I haven’t done any detailed analysis, but that was my finding.

Glen

[quote name=‘sixnin9’]Brian,

Your steps look correct. The one thing I can’s see in those screenshots is the permissions settings for the 2 new directories you created and the new .tpl. Try setting those to 777 and check the storefront to see if it worked.

Glen[/QUOTE]



I changed the permissions on both directories and the tpl to 777, but no change. Anything else you might need to see?

I don’t see a screenshot of your options_modifiers.override.tpl - can I see that?

I will post that this evening when I get home from work. Thanks for taking the time to work with me on this Glen.

[quote name=‘sixnin9’]I don’t see a screenshot of your options_modifiers.override.tpl - can I see that?[/QUOTE]



Glen, here is the code taken from my tpl file. I copied and pasted from this thread so it should be the same.



{if $vr.modifier|floatval}{if $product.base_price NE "0.00"}({include file="common_templates/modifier.tpl" mod_type=$vr.modifier_type mod_value=$vr.modifier+$product.base_price display_sign=false}){/if}{/if}




I’m also working on jpg prt sc again and am getting ready to post those

Here are better screen shots I have and here is my code in the tpl file:



{if $vr.modifier|floatval}{if $product.base_price NE "0.00"}({include file="common_templates/modifier.tpl" mod_type=$vr.modifier_type mod_value=$vr.modifier+$product.base_price display_sign=false}){/if}{/if}

my changes addon active.jpg

tpl file in the products directory.jpg

products directory.jpg

my_changes directory file in the just skin.jpg

Here are my dropdowns showing the variants. I did clear the admin by adding the ?cc at the end of the admin php url and then ?ct. I also cleared the browser cache. before Checked the storefront.

added variant to price.jpg

Variant dropdown menu.jpg

I am wanting to learn these codes, can someone breakdown what each of these codes are saying?:confused:






{if $vr.modifier|floatval}



{if $product.base_price NE "0.00"}




({include file="common_templates/modifier.tpl" mod_type=$vr.modifier_type mod_value=$vr.modifier+$product.base_price display_sign=false})





{/if}{/if}

Brian, let’s make sure the options_modifiers.override.tpl is even being recognized. Replace the contents of that file with “TEST” and reload the storefront. The word “TEST” should now appear in the option dropdown.

Glen, I replaced all the code in the .tpl file with TEST



Then cleared all cache, but the dropdown remains the same in the storefront.



Is it possible that it’s not recognizing because I’m using the Cpanel’s file manager to edit in the code? I haven’t used FTP in a long while, but if you think that could be the reason, I can try dusting off that part of the brain and entering through FTP.

Brian,

I have no idea why the My Changes add-on is not working for you. At this point, you’re probably better off just making the change directly to the original .tpl file.



Open /skins/yourskin/customer/views/products/components/product_options.tpl and replace```php {hook name=“products:options_modifiers”}{if $vr.modifier|floatval}({include file=“common_templates/modifier.tpl” mod_type=$vr.modifier_type mod_value=$vr.modifier display_sign=true}){/if}{/hook} ```with```php {hook name=“products:options_modifiers”}{if $vr.modifier|floatval}{if $product.base_price NE “0.00”}({include file=“common_templates/modifier.tpl” mod_type=$vr.modifier_type mod_value=$vr.modifier+$product.base_price display_sign=false}){/if}{/if}{/hook} ```



Clear your site cache and reload the storefront. Should work now.



Glen

Thanks Glen, I’ll try it this evening.

Thanks so much Glen. That worked and looks great. Exactly what I was looking for.