News:

Looking for documentation? Take a look on our wiki

Main Menu

Adding text inside createpricediv before price

Started by gfxpixeldesigns, September 28, 2012, 23:30:16 PM

Previous topic - Next topic

gfxpixeldesigns

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 ?

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

gfxpixeldesigns

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.

PRO

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

gfxpixeldesigns

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

PRO

in your "price configuration" do you have it checked?


gfxpixeldesigns

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.