View Single Post
  #11  
Old 07-07-2014, 09:53 PM
 
Ben G Ben G is offline
 

Advanced Member
  
Join Date: Nov 2006
Posts: 100
 

Default Re: Show Price in Price Variant As Price

Awesome code Mike - Thanks! Works great in 4.6.3

Quote:
Originally Posted by Mike SSI
{math equation="price_modifier+current_price" price_modifier=$o.price_modifier current_price=$product.taxed_price format="%.2f" assign=total_variant_price}
{currency value=$total_variant_price plain_text_message=1}[/code]

The code above by totaltec works great but it doesn't show the cost of the first option in the list.

This code will show the cost of first option in list also:

{if $v.is_modifier eq 'Y' and $o.price_modifier ne 0}
 (
{if $o.modifier_type ne '%'}
{math equation="price_modifier+current_price" price_modifier=$o.price_modifier current_price=$product.taxed_price format="%.2f" assign=total_variant_price}
{currency value=$total_variant_price plain_text_message=1}
{*** disable orig code currency value=$o.price_modifier display_sign=1 plain_text_message=1***}
{else}
{$o.price_modifier}%
{/if}

{else}
 ({currency value=$product.taxed_price plain_text_message=1}
{/if}
)

Building on your code
  • to show actual calculated price instead of % modifier
  • to stop the incorrect prices showing in the variant drop downs (the last else statement made the base price show next to all variants [as opposed to product options])
you can use this :
Quote:
{* {if $v.is_modifier eq 'Y' && $o.price_modifier ne 0} *}
{if $v.is_modifier eq 'Y'}
 (
{if $o.modifier_type ne '%'}
{math equation="price_modifier+current_price" price_modifier=$o.price_modifier current_price=$product.taxed_price format="%.2f" assign=total_variant_price}
{currency value=$total_variant_price plain_text_message=1}
{* {include file="currency.tpl" value=$o.price_modifier display_sign=1 plain_text_message=1} *}
{else}
{* {$o.price_modifier}% *}
{math equation="price_modifier*current_price/100+current_price" price_modifier=$o.price_modifier current_price=$product.taxed_price format="%.2f" assign=total_variant_price}
{currency value=$total_variant_price plain_text_message=1}
{/if}
)
{/if}

Works in 4.6.3

Further if using Variants aswell as basic Product Options, Cheries Code works a treat :

Quote:
{foreach from=$variants item=vv}
{foreach from=$vv.options key=vvk item=vvo}
{if $o.optionid eq $vvk}
{include file="currency.tpl" value=$vv.taxed_price plain_text_message=1}

{/if}
{/foreach}
{/foreach}

You can combine both Mikes & Cheries code as follows and calculated prices will show in each of the product options and product variants.

Quote:
{* {if $v.is_modifier eq 'Y' && $o.price_modifier ne 0} *}
{if $v.is_modifier eq 'Y'}
 (
{if $o.modifier_type ne '%'}
{math equation="price_modifier+current_price" price_modifier=$o.price_modifier current_price=$product.taxed_price format="%.2f" assign=total_variant_price}
{currency value=$total_variant_price plain_text_message=1}
{* {include file="currency.tpl" value=$o.price_modifier display_sign=1 plain_text_message=1} *}
{else}
{* {$o.price_modifier}% *}
{math equation="price_modifier*current_price/100+current_price" price_modifier=$o.price_modifier current_price=$product.taxed_price format="%.2f" assign=total_variant_price}
{currency value=$total_variant_price plain_text_message=1}
{/if}
)
{/if}
{/strip}
{* Added to show calculated price in variants *}
{if $logged_userid gt 0 or $config.Appearance.hide_prices_if_no_login ne 'Y'}
{foreach from=$variants item=vv}
{foreach from=$vv.options key=vvk item=vvo}
{if $o.optionid eq $vvk}
(
{include file="currency.tpl" value=$vv.taxed_price plain_text_message=1}
)
{/if}
{/foreach}
{/foreach}
{/if}
{* Added to show calculated price in variants *}
</option>

I've got the code working now in 4.6.3 and it is also be working with BSCE Checkbox Radio Mod for Product Options (a little patching needed) and you can also put the same code into X-Cart Mobile Skin.

Now drop downs for product options and product variants look almost identical and each line has the final price rather than the modifier. Thanks to all for helping
__________________
Ben
X-Cart 4.6.6 Gold Plus - lots of modules
X-Cart 4.7.9 Gold Plus - lots of modules
Reply With Quote