VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Aleksej on March 11, 2022, 07:24:04 AM

Title: Language constant for the buy button [solved]
Post by: Aleksej on March 11, 2022, 07:24:04 AM
Hello. I made an override for "addtocartbtn.php" file:

<?php
/**
 *
 * loads the add to cart button
 *
 * @package    VirtueMart
 * @subpackage
 * @author Max Milbers, Valerie Isaksen
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2015 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @version $Id: addtocartbtn.php 8024 2014-06-12 15:08:59Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');

if(
$viewData['orderable']) {
echo "<a type='submit' class='addtocart-button' href='https://aleksius.com/' target='_blank' rel='nofollow noopener'><span class='mybuy-button'>Buy</span></a>";

/* echo '<input class="addtocart-button" value="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'" title="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'" />'; */
} else {
echo '<span name="addtocart" class="addtocart-button-disabled" title="'.vmText::_'COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT' ).'" >'.vmText::_'COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT' ).'</span>';
}



Now, by clicking on the buy button, the site page opens:

echo "<a type='submit' class='addtocart-button' href='https://aleksius.com/' target='_blank' rel='nofollow noopener'><span class='mybuy-button'>Buy</span></a>";

Everything works fine. But I need multilingual support. How to change this code so that instead of the word "Buy" I can use a language constant "COM_VIRTUEMART_CART_ADD_TO"? Thanks in advance for your reply.
Title: Re: Language constant for the buy button
Post by: GJC Web Design on March 11, 2022, 09:11:53 AM
echo "<a type='submit' class='addtocart-button' href='https://aleksius.com/' target='_blank' rel='nofollow noopener'><span class='mybuy-button'>".vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' )."</span></a>";
Title: Re: Language constant for the buy button [solved]
Post by: Aleksej on March 11, 2022, 11:37:54 AM
Thank you very much. That helped. The question is closed.