VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gfxpixeldesigns on September 28, 2012, 23:30:16 PM

Title: Adding text inside createpricediv before price
Post by: gfxpixeldesigns on September 28, 2012, 23:30:16 PM
Hi,

I'm looking for a way to add text inside the createpricediv and before the price.

For instance the default_showprices code is:

echo $this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

I would like this to ouput something like "You Save: discount amount"

How would i add text inside the createprice div please ?
Title: Re: Adding text inside createpricediv before price
Post by: jenkinhill on September 29, 2012, 11:18:17 AM
Maybe use the language manager to add a new variable eg COM_VIRTUEMART_PRODUCT_DISCOUNT_SAVE="You Save:"

Then echo that variable in the div. Play with the position until it is right for your layout.
Title: Re: Adding text inside createpricediv before price
Post by: gfxpixeldesigns on September 29, 2012, 12:02:03 PM
Thanks for the suggestion.

Do you know how i would echo the variable into the code.

I tried

if ($this->product->prices['discountAmount']>0) echo $this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_SAVE', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

but this just breaks the you save section.
Title: Re: Adding text inside createpricediv before price
Post by: PRO on September 29, 2012, 12:55:14 PM
gfxpixeldesigns,

dont you just need to change the text?

Doesnt it already say

"Discount" 

just change

THIS
COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT

to this
COM_VIRTUEMART_PRODUCT_DISCOUNT_SAVE_AMOUNT

    echo $this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_SAVE_AMOUNT', $this->product->prices);

then do a language override
http://forum.virtuemart.net/index.php?topic=92944.0
Title: Re: Adding text inside createpricediv before price
Post by: gfxpixeldesigns on September 29, 2012, 14:11:53 PM
Quote from: PRO on September 29, 2012, 12:55:14 PM
gfxpixeldesigns,

dont you just need to change the text?

Doesnt it already say

"Discount" 

just change

THIS
COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT

to this
COM_VIRTUEMART_PRODUCT_DISCOUNT_SAVE_AMOUNT

    echo $this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_SAVE_AMOUNT', $this->product->prices);

then do a language override
http://forum.virtuemart.net/index.php?topic=92944.0

Now that you mention it, no it doesnt say anything which got me wondering if the language was even working.

So i checked the others such as base price and all are working as expected.

I then opened my language file to check COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT was there and it is.

COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT="Discount: "

I added a language override but still no text showing.

So i then started to change the createpricediv name

echo $this->currency->createPriceDiv('test', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

The above with test as the name didnt seem to register, after refreshing my div class was just 'pricesalesprice' with no mention of test.

I then tried changing it to a known class name 'baseprice'

echo $this->currency->createPriceDiv('basePrice', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

This registered and immediately i had my text showing.

So it seems the problem lies somewhere with the createpricediv class name.

I need to call it something unique, ideally discountAmount so how would i go about calling it that without the text being removed ?

Thanks
Title: Re: Adding text inside createpricediv before price
Post by: PRO on September 29, 2012, 20:16:13 PM
in your "price configuration" do you have it checked?

Title: Re: Adding text inside createpricediv before price
Post by: gfxpixeldesigns on September 29, 2012, 21:03:33 PM
Quote from: PRO on September 29, 2012, 20:16:13 PM
in your "price configuration" do you have it checked?

Well i dont half feel silly  :-[.

The label wasnt checked in my pricing config.

All working as expected after checking it.

Thanks for pointing me to the solution.