Radiolist to checkbox?

  • Posts: 1119
  • Thank you received: 114
8 years 9 months ago #230413

Hi,

I am looking to have simple checkbox on checkout login view.
I turned on switcher and modified checkout login/view file and added this code to registration view file under email field:

<div class="checkout-switcher">
			
 <?php
	$values = array();
	$v = null;

        $v = JHTML::_('select.option', 2, JText::_('GUEST').'<br/>');
		$v->class = 'hikabtn-checkout-guest';
        $values[] = $v;
        

		$v = JHTML::_('select.option', 3, JText::_('HIKA_REGISTRATION').'<br/>');
		$v->class = 'hikabtn-checkout-simplified-pwd';
        $values[] = $v;
		$defaultSelection = '3';

	echo JHTML::_('hikaselect.radiolist',  $values, 'data[register][registration_method]', ' onchange="displayRegistration(this)"', 'value', 'text', $defaultSelection, false, false, true );
?>
			
  </div>

It works and is switching between registration and guest... However what i am looking to have is simple checkbox.
If checked it should switch to registration and back to guest if not.
Is there a way to change this code to checkbox?

I also tried to do what i need with custom field checkbox but it seems there is no way...

Regards

Last edit: 8 years 9 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 9 months ago #230445

Hi,

I don't see why you would use checkboxes for the switcher ?
It would mean that people could select several login/registration modes at the same time.
But if you select for example login, there is no need to select registration, and vice versa.
That's why it's actually made with radio buttons by default so that you can only select one of the options of the switcher.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 9 months ago #230485

Hi,

I would like to configure like this. Left side login, right side guest or register it depends on switcher....
So if you would check code i added only registration and guest radio. I need checkbox to have this. Left side login anr right side guest with checkbox would you like to register? If checked it would display registration. Simplified reg with password.
So if you could tell me how to change radio to checkbox i would be very greatful.

I added something like this:

echo '<input type="checkbox" name="data[register][registration_method]" id="data[register][registration_method]" checked="checked" value="3" onchange="displayRegistration(this)" />';

But it works only when checked.. How to call back guest view then unchecked?

Thanks

Last edit: 8 years 9 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 9 months ago #230556

So after some time I did what I need. I have added this to registration/view file under email field:

<?php
	$values = array();
	$v = null;
    
        $v = JHTML::_('select.option', 2, JText::_('GUEST').'<br/>');
		$v->class = 'hikabtn-checkout-guest';
        $values[] = $v;
        
		$v = JHTML::_('select.option', 3, JText::_('HIKA_REGISTRATION').'<br/>');
		$v->class = 'hikabtn-checkout-simplified-pwd';
        $values[] = $v;
		$defaultSelection = '2';

echo'<input type="checkbox" class="hika_check_box" name="data[register][registration_method]" id="hika-box" value="3"/>';

?>

And this in my template js file:
$(document).ready(function(){
    $('#hika-box').change(function(){
        if($(this).attr("checked"))
        {
	displayRegistration(this);
        }
        else
        {
	var guest = {
				value:  '2',
				checked: '1'
			};
	displayRegistration(guest);	
        }
    });
});

Just thinking now is this correct way or not?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 9 months ago #230583

Hi,

Yes, that's great !
Thank you for sharing your solution with the community.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 9 months ago #230661

Hi,

So after i have done css customization i found that it is not working, lol :(
It is asking password on guest...My checkbox only changes view from guest to registration and nothing more...
Applying original code with radiolist all works ok.

Tried a lot things but it seems i am missing something.

If you Nicolas could help me i would be really greatful cause i stuck with it.

Regards

Last edit: 8 years 9 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 9 months ago #230676

Hi,

The code you placed in your previous message looks good to me. Can you give a link to the page so that we can see what it does ?

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 9 months ago #230713

Hi,

You can try it here: kyra.lt/demo just add something to cart and process to checkout. Enter any email on guest and it will ask password even checkbox isn't checked....

I also tried to remove this code to see if it makes difference and nothing, it makes no difference...:

$values = array();
	$v = null;
    
        $v = JHTML::_('select.option', 2, JText::_('GUEST').'<br/>');
		$v->class = 'hikabtn-checkout-guest';
        $values[] = $v;
        
		$v = JHTML::_('select.option', 3, JText::_('HIKA_REGISTRATION').'<br/>');
		$v->class = 'hikabtn-checkout-simplified-pwd';
        $values[] = $v;
		$defaultSelection = '2';

But this code does all the job....


Thank you

Last edit: 8 years 9 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 9 months ago #230735

Hi,

I see that you've just added some display:none; CSS on the password fields...
So it's normal that it refuses the form.
The Checkout will only accept the registration modes that are selected in the HikaShop configuration "registration" option. So there, you need to make sure that you have both the simplified registration and the guest selected.
You'll probably have to modify the file "checkout" of the view "config" for your backend template for that.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 9 months ago #230797

Hi,

So I found I couldn't do it by my self so I have contacted @kishoreweblabs as usual and he did what I need.
Changed my js file code to this and it works:

$(document).ready(function(){

//	displayRegistration(guest);

var registration_method_name='data[register][registration_method]';
SelectdValue=2;

$('input[name="' + registration_method_name+ '"][value="' + SelectdValue + '"]').prop('checked', true);
  
    $('input[name="' + registration_method_name+ '"][value="' + SelectdValue + '"]').trigger('change');
	

    $('#hika-box').click(function(){

        if($(this).attr("checked"))

        {

SelectdValue=3;

  $('input[name="' + registration_method_name+ '"][value="' + SelectdValue + '"]').prop('checked', true);
   $('input[name="' + registration_method_name+ '"][value="' + SelectdValue + '"]').trigger('change');
	

          }else{


SelectdValue=2;

  $('input[name="' + registration_method_name+ '"][value="' + SelectdValue + '"]').prop('checked', true);
  
    $('input[name="' + registration_method_name+ '"][value="' + SelectdValue + '"]').trigger('change');



         }

    });

});

Thanks

Please Log in or Create an account to join the conversation.

Time to create page: 0.066 seconds
Powered by Kunena Forum