News:

Support the VirtueMart project and become a member

Main Menu

How add link to TOS

Started by pkubik, March 05, 2018, 11:04:36 AM

Previous topic - Next topic

pkubik

Hi,
I need to add two links to the confirmation TOS, see image 1. the second link is marked in red. I want to open an link highlighted in green on the image 1.png



In the code on line 64 I added a link. But the link does not want to open in a pop-up window as link highlighted in green. I want to open a window with information - Legal Information, or another article. On the image 2.png.
If this is the case, the link page does not open, only redirects to the white page. How should I do it right?



defined('_JEXEC') or die;

$hiddenFields = '';
$i = 0;
?>
<?php if(!empty($this->userFieldsCart['fields'])) : ?>
<?php foreach($this->userFieldsCart['fields'] as $field) : ?>
<?php if($field['hidden']) :
$hiddenFields .= $field['formcode'] . "\n";
else : ?>

<?php $toolTip = !empty($field['tooltip']) ? ' class="hover-tootip" title="' htmlspecialchars($field['tooltip']) . '"' ''?>
<?php if($field['name'] == 'customer_note' || $field['type'] == 'textarea') : ?>
<div class="customer-comment-group">
<label for="<?php echo $field['name'?>_field" class="comment">
<span<?php echo $toolTip ?>><?php echo $field['title'?></span>
<?php if($field['required']) : ?>
<span class="asterisk">*</span>
<?php endif ?>
</label>
<?php 
$field['formcode'] = str_replace('rows="1"''rows="3"'$field['formcode']);
if($field['required'])
{
$field['formcode'] = str_replace('<textarea''<textarea required="required"'$field['formcode']);
?>

<?php echo strpos($field['formcode'], 'class="') ? 
str_replace('class="''class="customer-comment proopc-customer-comment '$field['formcode']) : 
str_replace('<textarea''<textarea class="customer-comment proopc-customer-comment"'$field['formcode']); ?>

</div>
<?php elseif($field['name'] == 'tos') : ?>
<div class="cart-tos-group">
<?php
$required = ($field['required'] || VmConfig::get('agree_to_tos_onorder')) ? ' required="required" data-label="' JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS') . '"' '';

$this->cart->prepareVendor();

$tosValue = (is_array($this->cart->BT) && !empty($this->cart->BT['tos'])) ? $this->cart->BT['tos'] : 0;
$tosValue = (!$tosValue && !empty($this->cart->cartfields) && !empty($this->cart->cartfields['tos'])) ? $this->cart->cartfields['tos'] : 0;
// $checkbox = VmHtml::checkbox ($field['name'], $tosValue, 1, 0, 'id="cart_tos_field" class="terms-of-service"' . $required);
?>

<?php if(VmConfig::get('oncheckout_show_legal_info'1)) : ?>
<?php if($this->params->get('tos_fancybox'0)) : ?>
    <label for="cart_tos_field" class="checkbox prooopc-tos-label proopc-row">
<?php echo $checkbox ?>
<div class="terms-of-service-cont">
<p>Při pokračování v nákupu souhlasíte s <a href="#proopc-tos-fancy" class="terms-of-service" data-tos="fancybox"><?php echo JText::('COM_VIRTUEMART_CART_TOS_READ_AND_ACCEPTED'); ?></a> a berete na vědomí <a href="#vendor_legal_info" class="terms-of-service" data-tos="fancybox"><?php echo JText::('COM_VIRTUEMART_CART_PRIVACY'); ?></a> pro účel vyřízení objednávky.<p>
</div>
</label>
<div class="soft-hide">
<div id="proopc-tos-fancy" class="fancy-tos-container">
<div class="fancy-tos-head">
<button type="button" class="fancy-close"><span aria-hidden="true">&times;</span></button>
<h3 class="fancy-tos-title"><?php echo JText::('COM_VIRTUEMART_CART_TOS'); ?></h3>
</div>
<div class="fancy-tos-body">
<p><?php echo $this->cart->vendor->vendor_terms_of_service?></p>
</div>
</div>
</div>
<?php else : ?>
<label for="cart_tos_field" class="checkbox prooopc-tos-label proopc-row">
<?php echo $checkbox ?>
<div class="terms-of-service-cont">
<a href="#proopc-tos-fancy" class="terms-of-service" data-toggle="bootmodal"><?php echo JText::('COM_VIRTUEMART_CART_TOS_READ_AND_ACCEPTED'); ?></a>
</div>
</label>
<div class="bootmodal fade" id="proopc-tos-fancy" tabindex="-1" role="dialog" aria-labelledby="tosLabel" aria-hidden="true">
<div class="bootmodal-header">
<button type="button" class="close" data-dismiss="bootmodal" aria-hidden="true">&times;</button>
<h3 id="tosLabel"><?php echo JText::('COM_VIRTUEMART_CART_TOS'); ?></h3>
</div>
<div class="bootmodal-body">
<p><?php echo $this->cart->vendor->vendor_terms_of_service?></p>
</div>
</div>
<?php endif; ?>
<?php else : ?>
<label for="cart_tos_field" class="checkbox prooopc-tos-label proopc-row">
<?php echo $checkbox ?> <?php echo $field['title'?>
</label>
<?php endif; ?>
</div>
<?php else : ?>
<?php $i++; ?>
<div class="<?php echo $field['name'?>-group custom-cart-field-<?php echo $i ?>">
<div class="inner">
<label for="<?php echo $field['name'?>_field" class="<?php echo $field['name'?>">
<span<?php echo $toolTip ?>><?php echo $field['title'?></span>
<?php if($field['required']) : ?>
<span class="asterisk">*</span>
<?php endif ?>
</label>
<?php echo $field['formcode'?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>

<?php echo $hiddenFields?>

Jörgen

Use the userfield TOS ?

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

data-tos in your code ?
What is your fancybox javascript ?

pkubik

data-tos in code:

// Show TOS with Fancybox
if (VPOPC._('TOSFANCY')) {
if (!ProOPC.pluginLoaded('fancybox')) {
console.warn('jQuery.fancybox plugin is not loaded. Terms of Service may not display properly.');
return false;
}

var $content = $('div#proopc-tos-fancy'),
$wrapper = $content.parent(),
easing = $.easing && $.easing.hasOwnProperty('elastic') ? 'elastic' : 'fade';

$('[data-tos="fancybox"]').fancybox({
titlePosition: 'inside',
padding: 0,
showCloseButton: false,
centerOnScroll: true,
transitionIn: 'fade',
transitionOut: easing,
overlayOpacity: 0.8,
overlayColor: '#000',
onClosed: function() {
if (!$(this.href).length) {
$wrapper.html($content);
$('div#proopc-tos-fancy button.fancy-close').click(function(e) {
e.preventDefault();
$.fancybox.close();
})
}
}
});

$('div#proopc-tos-fancy button.fancy-close').click(function(e) {
e.preventDefault();
$.fancybox.close();
});
}

Studio 42

Why you dont trigger the original link?
$('[data-tos="fancybox"]').click(function(e){
  e.preventDefault();
$('"#original-tos-link").trigger('click');
}

replace original-tos-link with the real tos link ID
And why using data-tos="fancybox" and not an ID id="toslink2" for eg?