News:

Looking for documentation? Take a look on our wiki

Main Menu

Select Payment Page (Auto Check Payment Method)

Started by PRO, October 18, 2012, 20:03:09 PM

Previous topic - Next topic

PRO

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);
   });
");
?>

toad78

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).

PRO

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

toad78

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.

PRO

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



PRO

what version of vmart are you using

and what payment method is it?

toad78

VM 2.014 and Payment Method is Flat Rate Shipping.

PRO

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


toad78

I'm sorry. I'm multitasking and I obviously mucked that one up.

The Payment method is Authorize.net.

PRO

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


PRO


toad78

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>

toad78

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?