X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Show Price in Price Variant As Price (https://forum.x-cart.com/showthread.php?t=62916)

bf2017 03-09-2012 11:36 AM

Show Price in Price Variant As Price
 
Is there a simple code I can add so that on the products page the price variant shows the actual price of the product price variant instead of how much the variant will add to the price? It's really annoying for the customer to have to use a calculator to add the variant to the base price to get the total price.

Thanks.

4.4.4 Gold

totaltec 03-09-2012 11:50 AM

Re: Show Price in Price Variant As Price
 
What do you mean by simple code? If you find some "simple" code out there, let me know. Most code is not "simple"! :)

I'm not sure if this applies to variants and I haven't tested it at all, but for regular product options that are a price modifier look here:
/common_files/modules/Product_Options/customer_options.tpl
Near line 58:
{if $o.modifier_type ne '%'}
{currency value=$o.price_modifier display_sign=1 plain_text_message=1}
{else}
{$o.price_modifier}%
{/if}

So you could edit this and do some math:
{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}

Place the code above in place of:
{currency value=$o.price_modifier display_sign=1 plain_text_message=1}

There might be another way, but this will get the job done I think.

Hope that helps,

cherie 03-09-2012 02:02 PM

Re: Show Price in Price Variant As Price
 
I believe only the Price Modifier shows the amount added by the option (not variants).

Variants can be tricky. If there is just one variant option then in the same file totaltec mentioned the following code adds the total price for the variants to the drop-down menu. Before </option>:
PHP Code:

{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} 


bf2017 03-10-2012 01:12 AM

Re: Show Price in Price Variant As Price
 
Thanks for the replies. I am talking about the price modifier. I have an item that is $65.00. My price modifier is: (for sizes)

A.
B. +44
C. +154
D. +264
E. +374

So when you select the dropdown, it shows the above (which can be misleading to a customer). What I would like the dropdown to show is the total price:

A. $65.00
B. $109.00
C: $219.00
D. $329.00
E. $439.00

I just can't figure out the code.

totaltec 03-10-2012 07:13 AM

Re: Show Price in Price Variant As Price
 
Is my solution above not working? Or do I still not understrand what you want?

bf2017 03-10-2012 09:57 AM

Re: Show Price in Price Variant As Price
 
I tried the code above, but it didn't do anything. So I'm probably doing something wrong.

totaltec 03-10-2012 12:22 PM

Re: Show Price in Price Variant As Price
 
Are you using a skin other than light and lucid 3 column? If so you may need to make the modification to the corresponding template in your skin directory. You can make sure you are affecting the right template by placing a small character or phrase somewhere and checking for that in the source of the page. You can also use Webmaster mode to determine the right template.

bf2017 03-10-2012 01:42 PM

Re: Show Price in Price Variant As Price
 
Ah...Webmaster Mode. Forgot about using that. Used that, inserted the code, and bingo! Thanks so much. Perfect!

:D

Mike SSI 03-29-2012 05:55 AM

Re: Show Price in Price Variant As Price
 
{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}
&nbsp;(
{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}
&nbsp;({currency value=$product.taxed_price plain_text_message=1}
{/if}
)

loopsound 05-28-2013 03:46 AM

Re: Show Price in Price Variant As Price
 
What a great piec of code Mike SSL. Now the modifiers will make sense to my customer. Maybe this piece of code should be integrated as a display option in the next Xcart update? Or maybe just a repost to common changes post?

Thanks so much for this.

Ben G 07-07-2014 09:53 PM

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}
&nbsp;(
{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}
&nbsp;({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'}
&nbsp;(
{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'}
&nbsp;(
{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

mcanitano 07-15-2014 11:33 AM

Re: Show Price in Price Variant As Price
 
1 Attachment(s)
Does the code from the above post work if you have multiple product option sets of variants?

i.e. Color and Size are two product option sets (both variant types).

We're having trouble implementing it into our v4.5.5 store

The "finish" set changes what color you would like the product to be, this actually has a price change. The "door style" set does not change price. [See attached image]

Ben G 07-19-2014 08:41 PM

Re: Show Price in Price Variant As Price
 
Looks like it might need some more work.

I enabled multiple variants on a product and got similar result. Calculated price works but it shows the price of Variant Option 1 for both Variant Option 2a or 2b (all possible combinations).

I'll have a crack at it and see if we can solve.

Comment out this ;

Quote:

{*
{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}
*}

And it will hide the variant modifiers completely and only show the variant name.

Something to do with this code.

mcanitano 07-21-2014 10:37 AM

Re: Show Price in Price Variant As Price
 
Quote:

Originally Posted by Ben G
Looks like it might need some more work.

I enabled multiple variants on a product and got similar result. Calculated price works but it shows the price of Variant Option 1 for both Variant Option 2a or 2b (all possible combinations).

I'll have a crack at it and see if we can solve.

Comment out this ;



And it will hide the variant modifiers completely and only show the variant name.

Something to do with this code.


Thinking of it from a coding stand point it seems this may become a little difficult/ugly with multiple variants. Keep us updated if you figure it out!

mcanitano 08-15-2014 06:23 AM

Re: Show Price in Price Variant As Price
 
Any news on getting this to work?

Ben G 08-21-2014 06:40 PM

Re: Show Price in Price Variant As Price
 
Not yet - still only works for one set of variants.

xtech 09-04-2014 02:55 AM

Re: Show Price in Price Variant As Price
 
I want to add Market Price and Our price options in variant.How to do that?

mcanitano 03-03-2015 07:11 AM

Re: Show Price in Price Variant As Price
 
Any updates on this?

Price Modifiers work way better for customers, but not keeping inventory/having specific Sku's is not helpful for us.


All times are GMT -8. The time now is 02:06 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.