VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Clocked0ne on January 27, 2012, 11:54:26 AM

Title: CartVariant custom fields price display
Post by: Clocked0ne on January 27, 2012, 11:54:26 AM
Hi guys,

How can I have the price be replaced rather than the variant price adding onto the base price? Is this possible?

If not, how can I have the additional price of the variant displayed as - £x.xx extra or similar instead of the default - £x.xx

At the moment it does not make sense for my product when trying to choose a different size that costs slightly more, the smallest size is not 'FREE', there is just no additional charge over base price! (see images)

[attachment cleanup by admin]
Title: Re: CartVariant custom fields price display
Post by: Clocked0ne on January 31, 2012, 21:33:45 PM
No one has any advice here? I thought this would be an easy one to answer.
Title: Re: CartVariant custom fields price display
Post by: Clocked0ne on February 28, 2012, 03:18:42 AM
I'm really at a loss that no one has attempted to answer this yet, surely I am not the only one that thinks the lack of flexibility in how cartVariants are displayed (and indeed the default method) is stupid..?
Title: Re: CartVariant custom fields price display
Post by: merdan2005 on March 05, 2012, 15:01:42 PM
delete the default value "0" in the back-end. This will change the the "free"' to nothing.

For your first question see: http://forum.virtuemart.net/index.php?topic=96591.0
Title: Re: CartVariant custom fields price display
Post by: Clocked0ne on March 05, 2012, 15:57:40 PM
Hi merdan2005, thanks for the reply.

I have tried the removal and found that it didn't look right still, so instead I simply edited the php file  to remove the prices being shown on variants, now only the main price adjusts. It's not ideal, but its better - the link you posted was for a tax based issue, not directly related, but thanks :)
Title: Re: CartVariant custom fields price display
Post by: PRO on March 05, 2012, 18:07:27 PM
<?php $field->display = str_replace( '$', '+$', $field->display ); ?><?php echo $field->display ?>

^^ will add a + to the dollar value.

THEN: do a language override for the text
http://forum.virtuemart.net/index.php?topic=93360.msg306906#msg306906
Title: Re: CartVariant custom fields price display
Post by: Clocked0ne on March 05, 2012, 18:30:49 PM
Thank you, is that line to add the + still in the administrator/components/com_virtuemart/models/customfields.php file?
Title: Re: CartVariant custom fields price display
Post by: PRO on March 05, 2012, 20:00:05 PM
Quote from: Clocked0ne on March 05, 2012, 18:30:49 PM
Thank you, is that line to add the + still in the administrator/components/com_virtuemart/models/customfields.php file?

No, thats the views/productdetails/tmpl/default.php

There is no reason to change the administrator files for something so small.

Do a layouts override, and the changes will not get overwritten when you update
Title: Re: CartVariant custom fields price display
Post by: Zuske on March 09, 2012, 01:56:06 AM
i also want to add the + in front of the extra price display, because it makes sense.

so i put this code
<?php $field->display = str_replace( '$', '+$', $field->display ); ?><?php echo $field->display ?>
into views/productdetails/tmpl/default.php
but the page went blank
so where exactly do i place this code on which line, and do since i use the euro do i have the change the symbol?
Title: Re: CartVariant custom fields price display
Post by: PRO on March 09, 2012, 12:04:12 PM
Quote from: Zuske on March 09, 2012, 01:56:06 AM
i also want to add the + in front of the extra price display, because it makes sense.

so i put this code
<?php $field->display = str_replace( '$', '+$', $field->display ); ?><?php echo $field->display ?>
into views/productdetails/tmpl/default.php
but the page went blank
so where exactly do i place this code on which line, and do since i use the euro do i have the change the symbol?

in the add to cart form, you will see the cart attributes.

REPLACE this     <?php echo $field->display ?>

with this
<?php $field->display = str_replace( '$', '+$', $field->display ); ?><?php echo $field->display ?>