Add some text in Product details

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Mon Jul 29, 2013 12:16 pm
Reply with quote
Report this post
Hi, I need to display a text next to the product price like I have in https://negre.es/tienda/mobiliario/mesas.html (21% IVA incl.) in two languages (spanish and english). I have this text displayed in category/default.php:

Code: Select all
echo '<div class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";


I have the code in my productdetails/default.php:

Code: Select all
if (round($this->product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $this->product->prices['salesPrice']) {
               
               echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";
            }
            echo $this->currency->createPriceDiv ( 'discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE', $this->product->prices );
            if (round($this->product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $this->product->prices['salesPrice']) {
               echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $this->product->prices);
            }            
            echo $this->currency->createPriceDiv ( 'priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices );


and don't know why its not displaying the same text as in category?

Also for the category layout, how can I display first the price and next the text? Now is
(21% IVA incl.)1511,29 € and I need 1511,29 € (21% IVA incl.)

Thanks in advance,
Kind Regards,
User avatar
Gold Boarder

teitbite
Mon Jul 29, 2013 2:14 pm
Reply with quote
Report this post
Hi

This is heavily customized already :)

Please just show how it looks right now and how should it looks like. I'll try to make it according the requirements.
User avatar
Moderator

GK User
Mon Jul 29, 2013 2:50 pm
Reply with quote
Report this post
Hi,
yes, I know its heavily customized, it's only a lang text next to

Code: Select all
<?php echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);?>


to display always something like "21% IVA incl." in spanish and in english "21% tax incl.".

I think its easy but I'm not good at playing with the jtext variables.

Thanks in advance,

Kind regards,
User avatar
Gold Boarder

teitbite
Wed Jul 31, 2013 12:46 am
Reply with quote
Report this post
Hi

Acctually the code is pointing to the "createPriceDiv" function, so we would need to modificate this function ;/ I think we should replace this function with a regular text, so it will be easier to manage.
Than You just need to use a code construction like:

Code: Select all
<?php echo JText::_('TAX_MESSAGE'); ?>


next step would be to add this to languahe file for english and spanish.

Code: Select all
TAX_MESSAGE="21% IVA incl."


and

Code: Select all
TAX_MESSAGE="21% tax incl."
User avatar
Moderator

GK User
Wed Jul 31, 2013 10:08 am
Reply with quote
Report this post
Hi teitbite,
Awesome!! I just need to add a div style around the jtext in order to style the text.
See the results here: http://negre.es/tienda/entrega-rapida/b ... arge-.html ;)
I needed it because we are always going to display product with taxes, no matter the product.!

Thanks!

I would like to ask about changing the order of this text 21% IVA incl. 2237,29 € that's shown in
http://negre.es/tienda/mobiliario/mesas.html category page. What I need is to change the order, first display the price 2237,29€ and then the 21% IVA incl.
Seeing the code that controlls this, I see:

Code: Select all
echo '<div class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";


where should I change the order (21% IVA incl after the price)?

Thanks a lot, you rule!

Kind Regards,
User avatar
Gold Boarder

teitbite
Thu Aug 01, 2013 3:31 am
Reply with quote
Report this post
Hi

Ok. We have come to the place where I do not know what to do :)

Looks like we need to locate this createPriceDiv function and make changes to it. Unfortunatelly I cannot find it. Ok, lets try something different than.

Add this code to css:

Code: Select all
.catProductPrice .PricebasePriceWithTax {
position: relative;
padding-top: 15px;
}

.catProductPrice .PricebasePriceWithTax span {
position: absolute;
top: 0;
text-align: center;
width: 100%;
}
User avatar
Moderator

GK User
Thu Aug 01, 2013 11:10 am
Reply with quote
Report this post
Hi, I was thinking in changing the order here:

echo '<div class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";

first price and then (21% IVA...)
cannot we do this?

Regards,
User avatar
Gold Boarder

teitbite
Fri Aug 02, 2013 4:57 pm
Reply with quote
Report this post
Hi

This line You are showing me is loading just one function which is creating this text in wrong order. Trust me I wanted to change it there, but this is a very big function which is there for many other price values, so any changes to this function may cause problems in other part of the site. Also This function is in core VM files, so an update of component will be blocked.

I think CSS solution I provided is the less invasive method.
User avatar
Moderator

GK User
Sat Aug 03, 2013 11:19 am
Reply with quote
Report this post
Hi teitbite,
I have solved the issue in category layout by adding the code:

Code: Select all
echo $this->currency->createPriceDiv ('basePriceWithTax', '', $product->prices) . JText::_ ('COM_VIRTUEMART_IVA');
in the two languages :) see http://negre.es/tienda/mobiliario/mesas ... icina.html
but how can I style it?

I want to add it to : http://negre.es/tienda/mobiliario/mesas ... egra-.html too and I tried:

Code: Select all
 <?php
                  if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
                  echo '<div class="taxmessage">' . $this->currency->createPriceDiv( 'basePriceWithTax', 'COM_VIRTUEMART_IVA', $product->prices ) . "</div>";
               } ?>


but it doesn't appear... why? :angry:

Thanks,
Kind Regards,
User avatar
Gold Boarder

teitbite
Tue Aug 06, 2013 5:36 am
Reply with quote
Report this post
Hi

Ok :) You're much more advanced with VM than me now :D

I for sure can help with styling, but prices and tax information dissapeared now from site. I really do not know how to make it with this VM functions. I think I would try to remove tax infor from them somehow and than add it manually as we did before. That's the way I know I can help with.
User avatar
Moderator


cron