VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: PRO on October 18, 2012, 20:03:09 PM

Title: Select Payment Page (Auto Check Payment Method)
Post by: PRO on October 18, 2012, 20:03:09 PM
I was having customers that would type in their credit card #, but were not checking the "radio" button for the payment method.
They were getting frustrated.
This code will auto check the FIRST payment method.

views/cart/tmpl/select_payment.php

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
    $('input:radio:#payment_id_11').attr('checked',true);
   });
");
?>

change payment_id_11  to your payment id   

ALSO:
The "Terms of Service" checkbox is not validated on the billing page.
You can auto check that box for them.

THIS CODE works on the FIRST "checkbox" , so change it if you have other checkbox user fields.
views/user/edit_address_userfields.php

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
    $('input:checkbox:first-child').attr('checked',true);
   });
");
?>
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 04, 2012, 19:04:47 PM
Yes, I've seen (templatename/html/com_virtuemart/cart/select_payment.php) this and have tried to adapt the current code in this file:

<?php
     
if ($this->found_payment_method) {


    echo 
"<fieldset>";
foreach ($this->paymentplugins_payments as $paymentplugin_payments) {
    if (is_array($paymentplugin_payments)) {
foreach ($paymentplugin_payments as $paymentplugin_payment) {
    echo $paymentplugin_payment.'<br /><br />';
}
    }
}
    echo 
"</fieldset>";

    } else {
 echo "<h1>".$this->payment_not_found_text."</h1>";
    }


    
?>


With the code you provided only to be presented with no Payment method being displayed (meaning, a blank section).
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 04, 2012, 22:45:28 PM
Quote from: toad78 on December 04, 2012, 19:04:47 PM
Yes, I've seen (templatename/html/com_virtuemart/cart/select_payment.php) this and have tried to adapt the current code in this file:

<?php
     
if ($this->found_payment_method) {


    echo 
"<fieldset>";
foreach ($this->paymentplugins_payments as $paymentplugin_payments) {
    if (is_array($paymentplugin_payments)) {
foreach ($paymentplugin_payments as $paymentplugin_payment) {
    echo $paymentplugin_payment.'<br /><br />';
}
    }
}
    echo 
"</fieldset>";

    } else {
 echo "<h1>".$this->payment_not_found_text."</h1>";
    }


    
?>


With the code you provided only to be presented with no Payment method being displayed (meaning, a blank section).


what?

this code is to check the checkbox
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 04, 2012, 23:31:55 PM
I guess I'm not describing my situation correctly.

On the payment page (editpayment.html)  (where the user selects their payment method), considering this is the only payment method that is being used, I would like to have the radio button already selected. Using the code you provided does not give me the results I need.

Opening the views/cart/tmpl/select_payment.php page, I added the code you posted:

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
    $('input:radio:#payment_id_11').attr('checked',true);
   });
");
?>

Only to receives the result of no Payment Method listed on the 'editpayment' page.
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 05, 2012, 13:50:04 PM
Quote from: toad78 on December 04, 2012, 23:31:55 PM
I guess I'm not describing my situation correctly.

On the payment page (editpayment.html)  (where the user selects their payment method), considering this is the only payment method that is being used, I would like to have the radio button already selected. Using the code you provided does not give me the results I need.

Opening the views/cart/tmpl/select_payment.php page, I added the code you posted:

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
    $('input:radio:#payment_id_11').attr('checked',true);
   });
");
?>

Only to receives the result of no Payment Method listed on the 'editpayment' page.

did you change this
payment_id_11

Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 06, 2012, 16:39:20 PM
Yes.
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 06, 2012, 21:31:42 PM
what version of vmart are you using

and what payment method is it?
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 06, 2012, 21:33:49 PM
VM 2.014 and Payment Method is Flat Rate Shipping.
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 06, 2012, 22:20:18 PM
Quote from: toad78 on December 06, 2012, 21:33:49 PM
VM 2.014 and Payment Method is Flat Rate Shipping.

thats a shipping method???

this is for payment method

Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 06, 2012, 22:22:05 PM
I'm sorry. I'm multitasking and I obviously mucked that one up.

The Payment method is Authorize.net.
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 06, 2012, 23:19:05 PM
Quote from: toad78 on December 06, 2012, 22:22:05 PM
I'm sorry. I'm multitasking and I obviously mucked that one up.

The Payment method is Authorize.net.

does it show without the code?

I know 1 of the latest versions are having problems with payment methods showing
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 07, 2012, 00:03:11 AM
Yes.
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 07, 2012, 13:24:25 PM
Quote from: toad78 on December 07, 2012, 00:03:11 AM
Yes.

I have no idea what this could be.

Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 07, 2012, 15:04:10 PM
This is what the source code displays after trying to apply your code in VM 2.0.14.

<fieldset><input type="radio" value="1" id="payment_id_1" name="virtuemart_paymentmethod_id">
<label for="payment_id_1"><span class="vmpayment"><span class="vmpayment_name">Credit Card</span></span></label>
<br><span class="vmpayment_cardinfo">Please enter your Credit Card information:
    <table width="100%" cellspacing="0" cellpadding="2" border="0">
    <tbody><tr valign="top">
        <td width="10%" nowrap="" align="right">
        <label for="creditcardtype">Credit Card Type: </label>
        </td>
        <td><select name="cc_type_1" id="cc_type_1">
<option value="Visa">Visa</option>
<option value="Mastercard">Mastercard</option>
<option value="AmericanExpress">American Express</option>
<option value="Discover">Discover</option>
</select>
</td>
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: toad78 on December 07, 2012, 15:14:18 PM
I've managed to finally get your code working (operator error).

Would this code be sufficient to use for checkboxes as well, considering this is nothing more than a jquery script?
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on December 07, 2012, 15:37:25 PM
Quote from: toad78 on December 07, 2012, 15:14:18 PM
I've managed to finally get your code working (operator error).

Would this code be sufficient to use for checkboxes as well, considering this is nothing more than a jquery script?

I do the same for the "agree to terms of service" checkbox.

You just have to identify the checkbox selector correctly.

Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 20, 2013, 06:42:53 AM
Should these codes be inserted in the very beginning of the file or does it really matter?

Quote from: PRO on October 18, 2012, 20:03:09 PM

views/cart/tmpl/select_payment.php[/b]
<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
    $('input:radio:#payment_id_11').attr('checked',true);
   });
");
?>

change payment_id_11  to your payment id   


Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 20, 2013, 07:41:44 AM
And what I discover is that the information is not saved before Save button is pressed. Do you have any solution for that to suggest, please?
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on September 20, 2013, 16:34:49 PM
Quote from: maxispin on September 20, 2013, 07:41:44 AM
And what I discover is that the information is not saved before Save button is pressed. Do you have any solution for that to suggest, please?

what do you mean?

it should be close to the top of the file
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 20, 2013, 17:58:42 PM
Thanks for your reply Pro!

I mean that radio button selection is not registered by VM and it says, " Payment method not selected" .

From the customer point of view it is "selected". (Just not saved)
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on September 20, 2013, 20:22:25 PM
Quote from: maxispin on September 20, 2013, 17:58:42 PM
Thanks for your reply Pro!

I mean that radio button selection is not registered by VM and it says, " Payment method not selected" .

From the customer point of view it is "selected". (Just not saved)

I know it works on mine, my selected is "first" which is credit card.

Then, if they want to use paypal, or google checkout. They have to select it, and it works
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 20, 2013, 20:26:20 PM
Good to know. I have to make more tests.

Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 20, 2013, 22:24:00 PM
I can't get it work. The radio button is selected yes, but not submitted and it is launched  "payment method not selected"

I have tried to add there some jquery submits without luck.

e.g.

$("#paymentForm").submit();



Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on September 23, 2013, 01:38:01 AM
Quote from: maxispin on September 20, 2013, 22:24:00 PM
I can't get it work. The radio button is selected yes, but not submitted and it is launched  "payment method not selected"

I have tried to add there some jquery submits without luck.

e.g.

$("#paymentForm").submit();






nobody can help without a url
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 23, 2013, 06:31:31 AM
True. The store is at xyz.fi [because of hackers picking sites removed address]- click on text KAUPPA
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: PRO on September 23, 2013, 14:58:47 PM
that looks like 1 page checkout.

My code is not for 1 page checkout
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: maxispin on September 23, 2013, 21:45:14 PM
I changed checkout page back to multistep and the result is same. The option is selected as it should be. However, I must point out that, in multistep checkout you (the customer) wants to see save button and your code Pro is just perfect.

My original point was that, when user presses (or has already selected with ajax etc code) radio button, that information should be automatically saved for the use of system. In one page checkout view this is an issue (at least for me).

Thanks Pro for your responses and for checking my site!
Title: Re: Select Payment Page (Auto Check Payment Method)
Post by: tophatco on May 22, 2014, 04:19:47 AM
Since upgrading to 2.60a, Joomla 2.5.20... the jquery script mentioned previously in this thread no longer worked. 

What worked for me now was to add a modification of it at the top of select_payment.php

<?php
/************* Autocheck credit card ********************/
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
   $('#payment_id_4').prop('checked', true);
   });
");
?>

where payment_id_4 might need to be changed to reflect the payment_id_X you want to check.

Why VM doesn't have a default selection for payments I do not understand.  Time after time I have had customers go to Select Payment, only to fill out their credit card information, not check the radio button, hit save, and submit their order. There should at least be an error thrown if no payment type is selected.

The order is actually recorded in the Orders in VM when they do not check the radio button... but the order is not processed by credit card nor are confirmations of the order mailed to the vendor or the customer.